> 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.

It doesn't quite. You also have to look as the CGI spec, in this case this bit:

  http://hoohoo.ncsa.uiuc.edu/cgi/out.html

this specifies that the web server your script is talking to has to do some
funny header fiddling, such that if you pass an absolute URI in Location one
thing happens (the browser gets an HTTP redirect response even if you don't
set the staus code to match), but something else happens with relative ones.

> 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

That's right: if your script returns a relative path to the web server it will
do an 'internal redirect', where the content for a different URI will be
returned to the user without any special HTTP headers to let them know it's
different.

> That means that relative links do not work, and external scripts and
> stylesheets referenced relatively are not brought in. Bad.

Yes. Rooted URIs ('/script/poo.js') are your friend.

> The server is Apache, if that matters.

It doesn't. This behaviour is a 'standard', for better or worse, and the likes
of IIS will do exactly the same.

It is not one of the prettier aspects of the CGI standard.
and@doxdesk.com