[thelist] Location header question

John.Brooking at sappi.com John.Brooking at sappi.com
Tue May 25 12:55:21 CDT 2004


Hi, all,

   Can anyone recommend to me a good tutorial for the HTTP "Location:"
header? I've taken a look at the W3C HTTP 1.1 spec [1], but it doesn't seem
to address my question.

   I have been having problems with it, which I think I have just solved,
but I'd still like more information. In my CGI scripts (Perl, but it
shouldn't really matter, AFAIK), I have been redirecting to an HTML document
in my docs directory, by simply printing something like "Location:
/path/thispage.html\n\n". The browser goes to that page, but the address of
the script (such as "/cgi-bin/scriptname.pl") stays in the browser's address
bar (IE 6.0, Win XP, but it shouldn't really matter, AFAIK). Additionally,
any relative addresses in the HTML page create a full address relative to
the /cgi-bin directory, not the directory where the HTML document is. (I
think of it as the "current working directory" not being reset, to use
command-line parlance.) That means that relative links do not work, and
external scripts and stylesheets referenced relatively are not brought in.
Bad.

   What seems to be working is if I fully qualify the URL in the Location
header, such as:

    #!/usr/bin/perl -T
    use strict;
    use warnings;
    print "Location: http://www.shoestringcms.com/test/b.html\n\n";   #
fully-qualified version, works
    #print "Location: /test/b.html\n\n";   # partially-qualified version,
doesn't work

   You can see a simple example of all this at my web site [2]. The server
is Apache, if that matters.

   Any comments? I'd really like to see a formal explanation of what is
recommended and what is not in the HTTP Location header. This has the
makings of a good tip, as soon as I make sure I know what I'm talking about!

[1] ftp://ftp.isi.edu/in-notes/rfc2616.txt
[2] http://www.shoestringcms.com/test/a.html

John Brooking, Application Developer
Sappi Fine Paper
-- 
 
This message may contain information which is private, privileged or
confidential and is intended solely for the use of the individual or entity
named in the message. If you are not the intended recipient of this message,
please notify the sender thereof and destroy / delete the message. Neither
the sender nor Sappi Limited (including its subsidiaries and associated
companies) shall incur any liability resulting directly or indirectly from
accessing any of the attached files which may contain a virus or the like. 


More information about the thelist mailing list