Welcome to WebmasterWorld Guest from 50.19.0.90

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Perl redirect script

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

Full Member

10+ Year Member

joined:Nov 16, 2003
posts:221
votes: 0


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?

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

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 0


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 Sept 26, 2007 (gmt 0)

Junior Member from US 

10+ Year Member

joined:Nov 30, 2002
posts:162
votes: 0


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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members