Kiko has asked for the wisdom of the Perl Monks concerning the following question:

Hey, I have another question. I have used redirect("http://www.msn.com") o +n a netscape enterprise server and it works. Now i'm using it on a m +uch simpler server (Xitami) and for whatever reason it's not working. + Could it be because this is not correct? Thanks, Kiko

Replies are listed 'Best First'.
(Ovid) Re: Redirecting
by Ovid (Cardinal) on Dec 05, 2000 at 10:23 UTC
    If you post a code snippet, it will be much easier for us to debug. It looks like you are doing something like the following:
    use CGI qw/:standard/; print redirect("http://www.msn.com");
    That should produce a 302 status code, and a location header:
    Status: 302 Moved location: http://www.msn.com/
    Try telnetting to port 80 of your box and issuing the GET request manually. That's will get you a definitive answer to what's going on. If you're not sure how that works, check out this script which will generate the proper requests for you (and there are some good responses below that, too).

    You could also try printing an extra -- header("text/plain") -- before the redirect header. That will cause the redirect header to show up in the browser. However, if you are afraid that your server is messing with your headers or doing something else weird, then this would not be definitive.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: Redirecting
by repson (Chaplain) on Dec 05, 2000 at 10:16 UTC
    AFAIK redirect is supposed to 'do the right thing'...
    To check why it is not working, first run the script at the command line.
    If that doesn't work tell us the code you are calling redirect with.
    If that does work try talking direct to the server ie:
    % telnet server 80 GET /cgi-bin/redirect_me.pl HTTP/1.1
    If that doesn't work, CGI.pm can't figure out the right headers, or your server restricts headers that can be sent to clients.
    If it did work that way then your browser doesn't understand the headers it is getting.

    We can give more help if we know where things are going wrong.

    Note: headers sent should be something like this:

    Status: 302 Moved Location: http://www.msn.com