header("Location: ...") correct implementation
| From: | John Steele | Date: | Sun, 04 Nov 2001 16:12:17 +0000 |
| Subject: | header("Location: ...") correct implementation | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-73432@lists.php.net to get a copy of this message | ||
Hello,
After seeing multiple message concerning the Location response-header using relative URI's,
and having to change this in multiple open-source projects, I'd like to point out that the
correct behaviour only allows ABSOLUTE URI's.
This may work on certain clients with a relative URI, but should NOT be depended on!
As per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14
:
14.30 Location
The Location response-header field is used to redirect the recipient to a location other than the
Request-URI for completion of the request or identification of a new resource.
For 201 (Created) responses, the Location is that of the new resource which was created by the
request. For 3xx responses, the location SHOULD indicate the server's
preferred URI for automatic redirection to the resource. The field value consists of a single
absolute URI.
Location = "Location" ":" absoluteURI
An example is:
Location: http://www.w3.org/pub/WWW/People.html
I.E. header("Location: mypage.php") should not be used...
Just my .02 US dollars,
John