Reputation: 21995
Relative redirects (i.e. relative URLs in the HTTP Location: header) were originally not supported according to RFC 2616, section 14.30. However this was described as a "bug in the spec", and was later changed in RFC 7231, section 7.1.2. Thus relative redirects are now "officially supported".
My question is: Are there any known cases of HTTP clients (browsers, tools, libraries..) not supporting relative redirects?
Update: Alternatively, a valid answer could provide a exhaustive list of HTTP clients which are known to accept relative redirects, along with version number ranges.
Upvotes: 12
Views: 565
Reputation: 98921
"According to the HTTP protocol, the Location header must contain an absolute URI.[5] When redirecting from one page to another within the same site, it is a common mistake to use a relative URI. As a result most browsers tolerate relative URIs in the Location header, but some browsers display a warning to the end user."
From: http://en.wikipedia.org/wiki/URL_redirection#Using_server-side_scripting_for_redirection:
Personally speaking, I've been using relative redirects for many years and they work with every single desktop/mobile browser and search bots I've tested with.
You can test, for example, google bot by using the fetch as google
tool on the webmasters dashboard.
This is probably a bit outside of the scope but google also follows JavaScript
redirects (window.location
).
Upvotes: 0
Reputation: 2535
I was doing some research and it seems that in fact most browsers (and also Googles search bot) support the feature. I was not able to get a definitive list though. Some 10000 http clients may eventually exist, each of them has their own way to handle the header fields (some may even ignore it completely).
As RFC 7231 is quite new (2014) my recommendation would be to not count on it. Following Postel's law ("Be conservative in what you send, be liberal in what you accept") I think sticking with the definite standard is always a good idea and just adding the domain to the redirect isn't much trouble.
Upvotes: 4