If you're not a do-it-yourself kind of person, or don't have the ability to add CGI scripts to your web site, there are commercial solutions that do what redir.pl does. One of my favorites is ClickThruStats, which includes extensive reporting and analysis of the traffic clicking on your links.
Redir is a little Perl script I wrote to solve a couple of problems:
Redir is a very simple solution to this problem. On web pages or in email, rather than linking directly to some external site, you can link to your instance of redir, passing a token, which is then used to look up the external URL to actually go to.
For example, using the default table that comes with redir.pl below, the following:
http://yourserver.com/cgibin/redir.pl?ms
will redirect to:
http://www.microsoft.com
with two very important characteristics:
I've found that in the worse case scenario, where the link you originally targetted goes away completely, it's nice to change your redirection to point to a page of your own, which explains the links disappearance, and perhaps providing alternatives, depending on the original intent.
Redir.pl is very simple, mostly to show the concept of redirection. A more robust and scalable solution would use a database to contain the tokens and redirection URL. But as is, redir works nicely for many applications.
Redir is freeware. It's a server-side Perl script, so it assumes you have CGI capability and Perl on your web server.
Unfortunately because of today's litigious society, I also have to tell you the following:
By using redir you agree to assume all risk for its use. It may or may not meet your needs. It's extremely unlikely, but it might have bugs that could harm or delete files on your computer. Perhaps all of them. Puget Sound Software assumes no liability for any damage caused by your use of syncfile in any way.If you can't accept those terms, then don't use redir.
With that out of the way, I will also say that if you find a bug in redir I'll attempt to correct the problem and get you a new version for free. Since redir is freeware that last part is kinda silly, but it's my policy for all the software I'm providing here, free or not.
Here's redir.pl:
#!/usr/bin/perl
# redir
# given a single argument, either redirects to an alternative, if we have one,
# or redirect to that argument. Basically everything AFTER the ? on invocation
# is the argument (i.e. no argument parsing ... if you want that, then you'll
# need to modify this or use a different script).
#
# The #!/usr/bin/perl is required to locate the perl interepreter on *nix
# systems. Similarly, this file can have ONLY newlines at the end of the line
# on many *nix systems. No DOS-like CR-LF, only LF. If not, then the script
# will fail to run.
#
# History:
# 03-Sep-2002 LeoN Created
# 13-Aug-2003 LeoN Cleaned up for publication
#
# Copyright (C) 2003, Puget Sound Software LLC
#
# table of redirections
# key is any token you'd like to use, and the value is the corresponding
# URL to invoke.
#
# Using the entry below as an example,
#
# http://site/cgibin/redir.pl?pss
#
# would redirect to http://pugetsoundsoftware.com.
# Note that if the key is not found in the lookup table,
# then we'll attempt to redirect to the value of the key.
#
%mpOverrides = (
"ms" => "http://www.microsoft.com",
"pss" => "http://pugetsoundsoftware.com",
);
# Check input - url required.
#
$urlTarget = $ENV{'QUERY_STRING'};
if (!defined($urlTarget) || ("" eq $urlTarget))
{
_err ("Error in redirection: missing or malformed parameter");
}
else
{
# if in our hit-list, then repace the destination
#
if (defined ($mpOverrides{$urlTarget}))
{
$urlTarget = $mpOverrides{$urlTarget};
}
# output immediate redirect to destination
#
print "Location: $urlTarget\n\n";
}
sub _err
{
my $szErr = shift @_;
print "Content-Type: text/html\n\nPuget Sound Software Redirector $szErr\n";
}
Entire site Copyright Copyright © 2003 - 2008, Puget Sound Software LLC