# REDIR.PL 1.0 # Copyright (C) 1997 John Watson # email: dwatson@deltanet.com |
REDIR.PL is a simple little CGI script that will redirect browsers to a new URL. It can display a page telling the user they are about to be redirected as well as log the redirect. This can be useful for tracking clicks through a web site or just a nice way to say adios to folks leaving your site.
[top]
[top]
The REDIR.PL distribution is currently only available right here. Both archives below contain the same stuff -- they are just archived differently. You only need one.
[top]
REDIR.PL takes the following parameters. You can send these parameters using GET or POST in forms or in the URL:
Both parameters are optional. If url is not given, it is set to the name of the web server. If title is not given, it is set equal to url.
[top]
Setup
REDIR.PL is a CGI script. It is intended to be used with a web server that supports CGI.
You can use REDIR.PL right out of the box by simply placing it in your /cgi-bin (or equivalent) directory. REDIR.PL uses the following default values:
You can change these defaults by modifying the following variables in the source code:
Finally, modify the HTML in the body() subroutine to change the intermediate page displayed (if $output == 1).
Using REDIR.PL
There are a couple of different ways to use this CGI. The following examples assume you have installed REDIR.PL in your /cgi-bin directory.
The simplest way is to call REDIR.PL from anchors. The anchor can contain an image or logo of another web site or just text:
<a href="/cgi-bin/redir.pl?url=http://someserver/index.html&title=The title!">Bye bye!</a>
Remember, REDIR.PL can redirect to pages on the same server:
<a href="/cgi-bin/redir.pl?url=/path/indexhtml">Same server redirect</a>
Another neat way to use REDIR.PL is in a form. You see these kinds of forms on some sites with multiple-language versions of their content or as a quick way to jump to different areas:
<form action="/cgi-bin/redir.pl" method="POST">
<select name="url">
<option value="http://otherserver/">Go to some other server!
<option value="/path/index.html">Go to another section of my site!
<option value="telnet://telnetserver/">Telnet to the telnetserver!
</select>
<input type="submit" value="Go!">
</form>
I used the POST method in the above example but you can use GET if you like without any changes to REDIR.PL.
Logging
REDIR.PL records the following data in its log file:
Each log entry is on a new line and the fields are seperated by tabs.
[top]
[top]
Please let me know if you find any. Bugs or limitations. :)
[top]
Hmm... Probably the script can be made a little more flexible by putting the intermediate page's HTML in a whole other file and reading that at run-time. I have no plans to implement it though -- I leave it as an exercise for the reader! <grin>
[top]
None.
[top]
...back to John's Perl Scripts