Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl redirect script

         

frup

8:18 pm on Sep 17, 2007 (gmt 0)

10+ Year Member



I have a very simple Perl redirect script. It is two lines:

-----------------------------------------
#!/usr/local/bin/perl

print "Location: http://www.example.com\n\n";
-----------------------------------------

Is that enough? Am I missing something important? I would also like to implement a counter, so I can keep track of how many people access the redirect. How do I do that?

coopster

9:16 pm on Sep 17, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Before you redirect, update a file that maintains the count. Or you could always grep your access log and count the requests for the resource there as well.

The only other thing you may want to do here first is send out the correct header status if this is a permanent redirect. By nature, I believe this is going to be a 302 or temporary redirect. If you want a 301 permanent being sent off, you'll want to send off your own header first.

upside

6:27 am on Sep 26, 2007 (gmt 0)

10+ Year Member



The example above would result in a "302 Found" status header being sent. For a 301, try:

print "Status: 301 Moved Permanantly\nLocation: http://www.example.com/\n\n";