Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Perl redirect script



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

10+ Year Member

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


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?


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

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 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.


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";

Featured Threads

Hot Threads This Week

Hot Threads This Month