Reputation: 1115
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!
Upvotes: 9
Views: 5875
Reputation: 16595
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.
Upvotes: 5