Posted by Richard Hearne
Interesting case I came across yesterday. A URL which 301 redirected went to different URLs in different browsers.
First thought – the server was redirecting different UAs to different pages. But no, the redirect was exactly the same regardless of UA.
So how come different browsers ended up in different locations? In fact the Location was the problem:
HTTP/1.1 301·Moved·Permanently
Date:·Mon, 20 Jul 2009 16:33:14 GMT
Server: Microsoft-IIS/6.0
X-mhN: 4
X-Powered-By: ASP.NET
Location: http://www.example.com/pagename.html
Location: /
Content-Length: 0Content-Type: text/html
Cache-control: private
The problem was that the redirect header had two Location attributes. Firefox 3.5 followed the last Location value, while Chrome followed the first. In 2 different browsers the client ended up in different locations.
The answer: Each redirect header should have only 1 Location attribute, and the value should be a fully formed URL (a value of “/” is technically incorrect).
Hopefully this might help someone else debug a redirect which sends different browsers to different pages/locations.