Mobile app version of vmapp.org
Login or Join
Candy875

: What are the Consequences for using Relative Location Headers? According to the spec, Location headers used in a redirect require a server name HTTP/1.1 301 Moved Permanently ... Location: http://example.com/foo/baz/bar

@Candy875

Posted in: #301Redirect #Http #HttpHeaders #Redirects #Seo

According to the spec, Location headers used in a redirect require a server name

HTTP/1.1 301 Moved Permanently
...
Location: example.com/foo/baz/bar

However, in 2012, most web browsers will recognize a relative path and redirect you to the new location using the original server name

HTTP/1.1 301 Moved Permanently
...
Location: /foo/baz/bar


Are there any negative/surprising consequences to using the relative URLs in the Location headers? My particular concern is how Google/search-engines will interpret this, but if there's anything else I'm not thinking about I'd love to hear it.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Candy875

2 Comments

Sorted by latest first Latest Oldest Best

 

@Rambettina238

According to the current version of the HTTP/1.1 standard, RFC 2616, the value of the Location header must be an absolute URI.

However, in the draft standard prepared by the HTTPbis Working Group to eventually replace RFC 2616, this has been changed to allow relative URIs as well, apparently because:


"The definition of the Location header [in RFC 2616] differs in various ways of how at least Web browsers need to deal with them to interoperate with content on the Web"


In practice, AFAIK just about all major browsers and search engines do understand and accept HTTP redirects to relative URLs. However, until the HTTPbis draft some day becomes the official standard and gets widely adopted, there will always be some new or obscure user agents that implement the current standard to the letter and only accept absolute URLs. Thus, the safe thing to do, for now, is to only use absolute URLs in Location headers, as suggested by Postel's law:


"Be conservative in what you send, liberal in what you accept."

10% popularity Vote Up Vote Down


 

@Dunderdale272

Section 14.30 of the HTTP 1.1 RFC www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30 is not significantly different. I don't know that you're going to see any actual practical limitations for this.

The only time I've seen even a warning about this issue is when I used to test in Lynx and the location was not absolute it would warn you "Location value not absolute" -- but if I remember right it still would let you go to the new location. I just tested Lynx 2.8.7 and it appears it doesn't do that anymore, though that may be a configuration issue.

Now, you say:


My particular concern is how Google/search-engines will interpret
this, but if there's anything else I'm not thinking about I'd love to
hear it.


I believe that this warrants a test. I'd set up a url, put it in your site's xml sitemap, and have that url be a redirect as you describe. I think the thing to do is check it using Google Webmaster Tools and see if there are negative consequences.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme