When your script prints out a Location header, your web server should capture that adjust the status line accordingly. For example:
[nardo@ilona cgi-bin]$ cat loc.cgi #!/usr/bin/perl print "Location: http://www.google.com\n\n"; [nardo@ilona cgi-bin]$ telnet localhost www Trying 127.0.0.1... Connected to ilona. Escape character is '^]'. GET /cgi-bin/loc.cgi HTTP/1.0 HTTP/1.1 302 Found Date: Wed, 05 Jul 2000 20:25:56 GMT Server: Apache/1.3.9 (Unix) Location: http://www.google.com Connection: close Content-Type: text/html <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>302 Found</TITLE> </HEAD><BODY> <H1>Found</H1> The document has moved <A HREF="http://www.google.com">here</A>.<P> <HR> <ADDRESS>Apache/1.3.9 Server at 216.254.31.132 Port 80</ADDRESS> </BODY></HTML> Connection closed by foreign host.
Note the HTTP/1.1 302 line at the top of the headers. When I make a script which will print out this exact output, with the exception of having an HTTP/1.1 200 header rather than the 302, my browser will not follow the Location header and will display the "This document has moved" html. This is probably what is happening with your server, if this is what is happening you will need to consult the documentation for your web server (or try a search on deja) to find out if it is possible to change the status line.

In reply to Re: Why doesn't the Location header work? by nardo
in thread Why doesn't the Location header work? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.