Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Perl web redirect

by Abigail-II (Bishop)
on Jun 10, 2002 at 15:45 UTC ( #173202=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl web redirect
in thread Perl web redirect

Using CGI for this triviality seems like overkill.

#!/usr/bin/perl print "Location: http://www.somewhere.com\n\n"; __END__
Will do. Of course, using perl is overkill, you may as well write a one liner in C:
int main () {printf ("Location http://www.somewhere.com\n\n");}

Abigail


Comment on Re: Perl web redirect
Select or Download Code
Re: Re: Perl web redirect
by Fastolfe (Vicar) on Jun 10, 2002 at 22:43 UTC
    For the simple case, agreed. Unfortunately it's difficult to tell from the poster's question whether or not this was the script's sole purpose.
Re: Re: Perl web redirect
by little (Curate) on Jun 11, 2002 at 00:42 UTC
    Abigail,

    Please read the specs if you want to do it by hand and right. There is quite more to be remitted, eg. the HTTP Status code, which in this case would be "302", which means MOVED. No, I don't think that using CGI.pm would be overkill (what about tachyon's suggestion for a light weight module instead?), it just helps you to have easy acces to teh Interface without knowing each little detail. Additionallly it helps you to protect your server against attacks very easily.

    Another hint on CGI's redirection, the name for the parameter is "uri" not "location", eg.

    print redirect(-uri=>"http://www.perlmonk.org/", -nph=>1, -cookie=>$cookie)
    Please study what the output is to see what has to be remitted.


    Have a nice day
    All decision is left to your taste
      We are talking CGI here, not HTTP. A Location header is the proper CGI response, it's up to the web server to turn the CGI response into an HTTP response.

      You aren't terminating your emitted lines with a CR LF either - the server takes care of such details.

      Abigail

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-07-31 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (247 votes), past polls