Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Using Perl To Redirect To Other Pages

by thatguy (Parson)
on Dec 03, 2002 at 19:33 UTC ( #217322=note: print w/ replies, xml ) Need Help??


in reply to Using Perl To Redirect To Other Pages

quick and dirty:

my $url="http://www.foo.com"; my $t=1; # time until redirect activates print "<META HTTP-EQUIV=refresh CONTENT=\"$t;URL=$url\">\n";

or

use CGI; my $query=new CGI; print $query->redirect('http://www.foo.com');

Updated: changed the time until redirect so as not to break the back button per LTjake's suggestion.
-phill


Comment on Re: Using Perl To Redirect To Other Pages
Select or Download Code
Re: Re: Using Perl To Redirect To Other Pages
by LTjake (Prior) on Dec 03, 2002 at 19:52 UTC
    Minor point, but this "tip" says not to use META refresh for redirection.

    Perhaps
    print "Location: http://www.foo.com/\n\n";
    is a better "quick-n-dirty"?

    Update: Whoops. Fixed code - missed newlines - hat tip: Cody Pendant.

    --
    Rock is dead. Long live paper and scissors!
      print "Location: http://www.foo.com/";

      Doesn't that need a couple of newlines after it to work?
      --

      ($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
      I agree, Cody. Why do people submit solutions that require others to load the submitters HUGE (favorite) Library of overcoded functions when there is such simple solutions?

        If the question asked for how to use HTTP to redirect, I'd probably think to give the print "Location..." answer but when asked for cgi, even in lowercase, we do tend to think of CGI.pm. Plus, though the print "Loc..." works, it is short on headers. It's fine to do it yourself but doing it right is usually easier through an interface. Even one that is less than ideal.

        ~>perl -MCGI -le 'print CGI::redirect("http://perlmonks.org")' Status: 302 Found Location: http://perlmonks.org
        Because perlmonks isn't HTTP monks; because you didn't want to learn HTTP; because HUGE (favorite) Library of overcoded functions keeps you from having to learn HTTP.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://217322]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2014-12-25 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls