in reply to Returning to A Referring Page

If you need to retrieve the referring page name, use the environment variable $ENV{'HTTP_REFERER'}.You could try this out :
$jump_to = $ENV{'HTTP_REFERER'}; print "Location: $jump_to\n\n";

Replies are listed 'Best First'.
Re: Re: Returning to A Referring Page
by rob_au (Abbot) on Jan 20, 2002 at 13:06 UTC
    You will also need to incorporate a default value as you cannot always be sure that the HTTP_REFERER environment variable will be set. eg.

    $jump_to = $ENV{'HTTP_REFERER'} || 'http://www.yourwebpage.com'; print "Location: $jump_to\n\n";

     

    perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'

      Just to make it complete though:
      $jump_to = $ENV{'HTTP_REFERER'} || 'http://www.yourwebpage.com'; print "Status: 302 Moved\n"; # thats the spec print "Location: $jump_to\n\n";
      Some Browsers would ignore the redirection attempt without the correct status. But if you use CGI.pm it will do it for you :-)

      Have a nice day
      All decision is left to your taste
        I don't know about other webservers, but Apache changes the status according to the other headers. If there's a Location: header, the status will be 302.
        Status headers aren't sent as-is to the browser, they're in the first response line: HTTP/1.1 302 Moved.

        2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$