Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

http:/relative/path officially works?

I recently needed to do a redirect in php using:

header("Location: http:/relative/path");

which seems to work in all the browsers I have available to me (Safari, Chrome, Firefox). This also works when used in a standard link:

<a href="http:/relative/path">Link to relative path</a>

My question is whether this is a fluke, or a formal implementation. I need to confirm to my superiors that this is a known standard.

Thanks!

like image 608
paulguy Avatar asked Aug 22 '13 16:08

paulguy


People also ask

How do relative file paths work?

A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy.

What is relative path in URL?

A relative URL is a URL that only includes the path. The path is everything that comes after the domain, including the directory and slug. Because relative URLs don't include the entire URL structure, it is assumed that when linking a relative URL, it uses the same protocol, subdomain and domain as the page it's on.

How do you set a relative path?

Absolute and relative paths in script tools You can also set this option by right-clicking the script tool, clicking Properties, then clicking the General tab. At the bottom of the dialog box, check Store relative path names (instead of absolute paths).

Why is my img src not working?

Img src Not Working That means, when a web page loads, the browser has to retrieve the image from a web server and display it on the page. The broken link icon means that the browser could not find the image. If you've just added the image, then check that you included the correct image URL in the source attribute.


1 Answers

Per RFC 3986, under Section 4.2 or appendix A:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

where hier-part can be "//" for authority path-abempty, "/" path-absolute, path-rootless or path-empty.

If you think about it, when you use "http://", the "//" denotes the root of the available path. That's why different protocol schemes don't need it like Skype. It uses "skype:echo123?call" which will call the user "echo123". No "//" needed since there is no "root".

So yes, it's valid. But since that exact usage is a little off the normal pattern setup in today's browsers, your milage may vary. It does work in IE9.

like image 188
Steven V Avatar answered Oct 31 '22 18:10

Steven V