in reply to Re^2: cgi redirect
in thread cgi redirect

Did you still have the print header,start_html,h1('redirecting to a different page'); line before the print redirect?

CGI's redirect function sends a complete HTTP response to the web browser telling it that the page it requested moved somewhere else, with the URL to there.

$ perl -le ' use CGI qw/:standard/; print redirect("http://some.where.else"); ' Status: 302 Found Location: http://some.where.else

It looks like you're trying to redirect while displaying a page to the user. Something like

<html> <head> <meta http-equiv="REFRESH" content="5;url=http://localhost/html/te +st.html"> </head> <body> <h1>redirecting to a different page</h1> </body> </html>
CGI's redirect doesn't do that.

Replies are listed 'Best First'.
Re^4: cgi redirect
by Anonymous Monk on Nov 26, 2009 at 15:38 UTC
    Thanks keszler. I got it now. Happy Thanksgiving Day.
Re: cgi redirect
by Anonymous Monk on Nov 26, 2009 at 16:55 UTC
    Hi Keszler,

    I am trying to write the stuff in a html file and then trying to redirect to that html page, then also it's not redirecting. Below is he code:

    open(F,">$DIR_html") or die "Cannot create $DIR_html: $!"; print F start_html("-title" => "Search in progress","-head" => ["<meta + http-equiv=refresh content=20>"]); print F h1("Search in progress"); print F p("The search is still in progress. Please reload this page." +); print F end_html; close(F); } defined(my $childpid = fork) or die "Cannot fork: $!"; if ($childpid) { print redirect("http://localhost/htmlfilewritten"); }

    Any idea why it's not working? In this case it should work, cause whatever the header,start_html I have written to file and not to STDOUT.

      Can you be a little more specific than "not working"? What is actually happening? (My crystal ball is in the shop.)

        not working means, it's not redirecting at all to the html page. I have pasted the code. what I am trying to do is ... while my cgi script processes I will display this temporary page and when processing gets complete, I will overwrite the temporary page with the main result and it will be displayed.