homepage Welcome to WebmasterWorld Guest from 54.205.241.107
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Perl redirect script
frup

10+ Year Member



 
Msg#: 3453200 posted 8:18 pm on Sep 17, 2007 (gmt 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?

 

coopster

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



 
Msg#: 3453200 posted 9:16 pm on Sep 17, 2007 (gmt 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.

upside

10+ Year Member



 
Msg#: 3453200 posted 6:27 am on Sep 26, 2007 (gmt 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";

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved