If all browsers followed the W3 standards the world would be a better place...

They say "...field value consists of a single absolute URL."
                                                        ^^^
I think they mean URI because the example says "absoluteURI", not URL.

An absolute URI is

/some/location

But so is

http://www.somehost.com/some/location

Both are valid URIs and both absolute.  One is more qualified than the other.

A relative URI is

some/location

which is incorrect, and not what I meant in my message.

Which brings us to the next point...

By using relative *URLs* such as /some/location, you avoid changing 
the location field in the browser window, which is often desired.  If 
you use an absolute *URL*, the location field changes to the absolute 
URL.

You can try it with a simple perl script CGI.

#!/usr/bin/perl
print "Location: /some/location/\n\n";

or

#!/usr/bin/perl
print "Location: http://somehost.com/some/location/\n\n";


Robert Landrum



>On Thu, 8 Feb 2001, Robert Landrum wrote:
>
>> The problem is that Apache does not put the "Set-Cookie" before the
>> "Location" when generating headers.  To fix this, you need to build
>> the header yourself.  I've found that this works with Netscape and
>> IE, but with IE, the place where you redirect to does not have access
>> to the cookie that you just set.  All subsequent pages are able to
>> read the cookie... It's a bug in IE.
>>
>>
>>      my $cookie = Apache::Cookie->new($r,
>>          -name => "MYCOOKIE",
>>          -value => "VALUE",
>>          -path => "/some/cookie/path"
>>      );
>>
>>      my %headers = (
>>          "Location" => "/some/redirect/location",
>
>I'd like to mention that the Location header MUST be absolute, NEVER
>relative.  Absolute means that it must include the scheme!
>
>http://www.w3.org/Protocols/rfc2068/rfc2068
>
>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 URL for automatic redirection to the resource. The
>   field value consists of a single absolute URL.
>
>          Location       = "Location" ":" absoluteURI
>
>   An example is
>
>          Location: http://www.w3.org/pub/WWW/People.html
>
>
>-jwb


Robert L. Landrum
Senior Programmer
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
UNIX was not designed to stop its users from doing stupid things,
as that would also stop them from doing clever things. --- Doug Gwyn

Reply via email to