Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Modified Dynamic Ad Link Redirection Perl Script

This mod allows for adding 1x1 tracking gifs to the links.cgi script

11:15 pm on Jul 26, 2004 (gmt 0)

10+ Year Member

This is part of a multi-pronged solution to thwart ad blocking software and reduce the size of your affiliate ad links, thus speeding up the load time of web pages with numerous text ad links. The main part is a Perl CGI script named links.cgi.

Links.cgi is freeware and is called a dynamic redirection script. It was written by Jeremy OConnell, of Cyberweb Solutions, to allow his company's affiliates to conceal their ad links from their html code, thus from ad blocking software as well, then to redirect the browser to the sponsor's page for the product who's link was clicked. Jeremy has graciously allowed his script to be modified, and renamed, and to be used by anyone, so long as the headers, with the credits, remain intact.

This (freeware) Perl script is currently available for downloading, from [cyberws.com ]. If the WebmasterWorld TOS permits it I will be glad to post the entire script in a followup to this Post.

I advise that anybody who uses this Perl script and these redirect codes should think about changing the name of the script. This will protect it in case the ad blocking programmers decide to add it to their hit-list of blocked scripts. See [webmasterworld.com ], for a list of already blocked scripts, words and paths in just one popular ad blocker.

The existing script uses a companion text file, in the same (cgi-bin) folder as the script, named links.txt, which has a line-by-line, comma separated list of ad codes and descriptions. Anything before the first comma represents the assigned alias for that link. For example, if you use numbers for each link, in the query string appended to the following code:

<a href="cgi-bin/links.cgi?l=99">Product ID</a>
, the 99 would represent a unique aliased link, in list.txt. The affiliate click codes follow the first comma and preceed the second one. Anything after the second comma is disregarded by the script and treated as a user comment.

I use Commission Junction and Linkshare programs, both of which require all text links (and even the occasional banner link at Linkshare) to include an accompanying download of a 1x1 pixel tracking gif. No gif, no commission! Since the existing script does not take this into account I devised a modification to include any tracking gifs that are required, but to download them only when that link code is clicked upon.

Here's how I did this. If you have a text editor that provides line numbers, such as NoteTab Pro (my editor), and you open a fresh copy of links.cgi in it, the changes begin on line #30, with this line of code:


I have modified that line to include a tracking gif variable, thusly:


Then, I added a new line, after line #32, with this variable in it:

[b]$linkgif=~ s/^\s+//;[/b]

The new array of variables in this important section should now read as follows, beginning on the original line #29:

foreach $link (@links) {
$linknum=~ s/^\s+//; #remove initial space
$linkurl=~ s/^\s+//; #remove initial space
$linkgif=~ s/^\s+//; #remove initial space
$linkdesc=~ s/\s+$//o; #remove hard return

Our new $linkgif variable has been declared, but how do we actually use it?
The answer became clear when I read the following original Print codes:

if ($l eq "$linknum") {
print <<EOF;
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=$linkurl">
all style and other Meta codes
<body snip>
<p align=center>
<a href=$linkurl>Click here should your browser fail to move you forward!</a>

I looked at that and realized that the $linkgif variable needed to go in the body, right after the anchor link to $linkurl, and that it needed to have it's style attributes set to img {width:1px; height:1px; border:0}, in the style section of the head. I also increased the http-equiv delay time from 0 to 3 seconds, to insure that the tracking gif has time to download (usually 43 bytes). I also changed the body text a bit. Here is my relevant modification to the head and body Print sections:

<META HTTP-EQUIV="Refresh" CONTENT="[b]3[/b];URL=$linkurl">
[b]img {width:1px;height:1px;border:0}[/b]
<br><br><p align=center>Please wait a few seconds while we connect to the requested product's page.<br><br><a href="$linkurl">Click here if your browser doesn't automatically forward you within 10 seconds</a>[b]<img src="$linkgif" alt="">[/b]</p>

Because I have added another variable and comma into the links.txt code-strings, I had to figure out how to account for the absence of a tracking gif. Simple, put nothing between the second and third commas. No space is required, since the script strips out blank spaces after the commas anyway. However, it is very important to include all three commas in each line.

Here is a "cleansed" example of one line of aliased link code, including a tracking gif and a comment (All on one line in links.txt):

33, ht*p://www.qksrv.net/click-********-********, ht*p://www.qksrv.net/image-********-********, So and So's product page

You'll notice that I have included a space after each comma, to make it easier to read the codes. The script ignores these spaces when executed. Every link, with all of it's codes and sections must be on one line each. There should not be any blank lines between link codes, even at the end of the list. It should terminate without a carriage return, after the last character, on the last line of code.

I have tested this modified script with over 50 affiliate text links, some with tracking gifs and some without, and everything works perfectly. I have not tried to use it with banner ads, since that would be redundant. How can somebody click on a banner that hasn't been displayed yet?

I have used it with banner ads by using this technique:

First, I saved all the banners I liked, reduced them in Photoshop, renamed them and FTP'd them to a directory on my server.

Second, I obtained the CJ codes for those products using either a text link, if available, or an 88x31 button sized ad, and copied them to a new text page in NoteTab.

Third, I created an aliased link (to the cgi script) in the webpage, followed by an image tag, with the desired banner served from my server, then a closing anchor tag.

Fourth, I put the relevant click codes, and either the image (88x31), or tracking gif codes into links.txt. If I used an 88x31 button, it will be called and downloaded from the ad server, but will not be displayed on the transfer page, because all images are styled as 1px by 1px, with no border.

Enuf for now. If I forgot anything important about this script I'll add it later.

If you are hosted on an Apache Web Server and are allowed to write your own .htaccess modifications, including Mod_Rewrite, you can use abbreviations for your affiliate link tags, then use .htaccess to expand and redirect them to the CGI script.

Here is a relevant example of long-form and abbreviated links and the additions to .htaccess that are required to expand and redirect it to the cgi script:

Cleansed example of a typical CJ affiliate link before reduction or redirection:

 <a href="ht*p://www.qksrv.net/click-********-****xxxxx" target="_blank" onmouseover="window.status='ht*p://www.zzzzzz.com';return true;" onmouseout="window.status=' ';return true;">Product or company description</a><img src="http://www.qksrv.net/image-xxxxxx-xxxxxxxx" width="1" height="1" border="0"> (298 bytes)

Here, the link code is changed to use the links.cgi script to redirect the link:

 <a href="cgi-bin/links.cgi/?l=99" target="xyz">Product or company description</a> (81 bytes)

Same link using shorthand version and Mod_Rewrite redirection:

 <a href="L/?l=99" target="xyz">Product or company description</a> (65 bytes) 

You will notice that although the shorthand version only shaves off an additional 16 bytes, it does hide the name and location of the cgi script from the source code, which is an added margin of protection from ad blockers or content thieves.

Here is the Mod_Rewrite activation, condition and rule, for use in your Apache .htaccess file, which will expand the abbreviated codes and redirect them to the cgi script named "links.cgi" (rename it as you see fit):

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^L/$ /cgi-bin/links.cgi?%1 [L]

I hope this makes sense and is useful to others who are trying to make a buck with affiliate ads. If you find any typos that I missed, please StickyMail me about them. Otherwise, please reply to the Forum so all can learn.


5:57 pm on Jul 27, 2004 (gmt 0)

10+ Year Member

If I read this right, your 1x1 GIFs still have obvious, predictable URLs.

lists qksrv.net for instance. Wouldn't it still block the request for the GIF?

6:24 pm on Jul 27, 2004 (gmt 0)

10+ Year Member

If I read this right, your 1x1 GIFs still have obvious, predictable URLs.
Wouldn't it still block the request for the GIF?

I'm not sure about that part yet. The redirect page is generated Server-Side, by CGI, on the fly, and the tracking gif is called by that cgi created html page, as it is transferring the visitor to the sponsor's website. I guess somebody with NIS can test that for us. One can temporarily re-style the gifs to 20x20px, with a 1px border, and a longer delay time, to see if they are still there, with the qsrv codes intact, after a few seconds, with ad blocking engaged. I don't have any ad blocking programs myself.

If that doesn't fix the problem I'll try another method of calling the tracking gifs, but they still must be called from the qsrv.net server, to ensure getting our commissions.

I wonder how the negotiations are going between CJ and Symantec? Symantec has the power to add or subtract servers, names and paths, from the ad blocking list, which is updated by their Live Updates. They can also change the default behaviour of this portion of NIS, but only if it suits their purposes.

Thanks for your input py9jmas!


4:52 am on Jul 29, 2004 (gmt 0)

10+ Year Member

Seems like a a useful script if you only have a small amount of affiliate links.

But what if you have 1,000s? I am wondering (I'm not a cgi programmer) if you could easily modify the code for direct product links?

so if your link looked like:


can you have addition to the url to look like


So the link redirect would combine the cloaked affiliate ID with product url.

I hope this makes sense and thank you in advance for your response.

1:00 am on Aug 27, 2004 (gmt 0)

10+ Year Member

Followup input:

I finally got to try looking at my website through a computer protected by Norton Personal Firewall, with automatic updates activated. While it blocked every single unencoded ad, including text links and Google text ads, it did not block my encoded links to the redirect script. Neither did it block the page that is generated before the redirect occurs, or the tracking gifs. Everything loaded, then the browser was redirected, with the tracking gifs intact.

I hope this helps someone else, who has the same concerns I have about ad blocking softweare.

I have modified the script a bit since posting it here, so if anybody wants my mods, send me a Sticky message and request it.


1:13 am on Aug 27, 2004 (gmt 0)

10+ Year Member

great script Wizcraft! can you post the updated one on here for all of us to share?

However, like ezwebdesign I have so many affiliate links that I don't think your solution would work for me. In addition to belonging to hundreds of different affiliate programs, I also like to deep-link to product specific pages within my sponsor's site, which means hundreds of thousands of unique URLs that need to be masked.

I second the need for being able to

so if your link looked like:


can you have addition to the url to look like


So the link redirect would combine the cloaked affiliate ID with product url.

Those ad blockers are doing some serious damage to our incomes! Who else has noticed a continual decline over the past year or so? I've never been so frustrated in my life. My post over at [webmasterworld.com...] also discusses this issue, although I've had no luck so far with trying to resolve it through mod rewrite (but I *really* don't know what I'm doing in that department..)


4:15 am on Aug 27, 2004 (gmt 0)

10+ Year Member


Forget trying to Mod_Rewrite this problem away. It ain't going to be doable.

I forgot that I answered ezwebdesign by Sticky, and didn't post it here. My script takes care of the aformentioned url added links also.

The following are sample link-codes for CJ and LinkSynergy text ads:

This code is a simple CJ text click and tracking gif link:
[b]52,ht*p://www.qksrv.net/click-******-*******, ht*p://www.qksrv.net/image-******-*******, [/b]Product description

This ad has a url added, to a product page:
[b]84,ht*p://www.qksrv.net/click-******-********?url=ht*p%3A%2F%2Fstore.l-f-l.com%2Fcgi-bin%2Fcp-app.cgi%3Frrc%3DN%26pg%3Dprod%26ref%3D9U261%26CMP%3DAFC-cj, , [/b]A High Capacity Battery

This is a LinkSynergy style ad:
[b]100,ht*p://click.linksynergy.com/fs-bin/click?id=*********&amp;offerid=12345.10000013&amp;type=3&amp;subid=0, ht*p://ad.linksynergy.com/fs-bin/show?id=********&amp;bids=12345.10000013&amp;type=3&amp;subid=0, [/b]Spam Killer

This one is without a tracking gif, but contains a blank space where on would go:
[b]49,ht*p://entier.ecosm.com/link/?********xx, , [/b]Mailwasher Pro

I don't know how much code it would take to slow down the script. If too many lines of encoded links becomes a problem one could simply create copies of the script, and add numbers to the name, like links6.cgi, and have each copy call a similarly numbered links.txt, as in links6.txt. There is a place in links.cgi where you can assign a different filename to the text file.

Here is the entire script, with my current mods in BOLD, and the writer's copyright notice in place. If any of y'all use this please keep his copyright in place. If you want to add a credit to me, that's fine also.

Begin contents of modified links.cgi:


#Change admin pass
$adminpass="(Your admin password goes here)";

##Created by Jeremy of Cyberweb Solutions, LLC
##You are free to use and modify this script so long as you leave these headers intact
##Distributing script is allowed as long as done so free of charge
##Version Dynamic Redirection System 1.1b - 1 Mar 04 :: Orginial release date - 21 Feb 04

[b]## Modified by Wizcrafts on August 27, 2004[/b]

#### Use this type of link to access the admin panel:
#### [b]http://www.YourDomainName.(com)/cgi-foldername/links.cgi?linkmin=y[/b]

[b]####You modify below this line at your own risk - YOU HAVE BEEN WARNED!####
$font="<font face=verdana size=2>";

###########System Code##############
print "Content-type: text/html\n\n";

if ($FORM{'linkmin'} eq "y") {&linkmin;}

@links = <LIST>;

foreach $link (@links) {
$linknum=~ s/^\s+//; #remove initial space
$linkurl=~ s/^\s+//; #remove initial space
[b]$linkgif=~ s/^\s+//; #remove initial space[/b]
$linkdesc=~ s/\s+$//o; #remove hard return
if ($l eq "$linknum") {
print <<EOF;
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="FRI, 13 APR 1999 01:00:00 GMT">
<meta name="robots" content="noindex,follow,noarchive">
<script language="JavaScript" type="text/javascript">
var image1 = new Image(1,1);
image1.src = "$linkgif";
var lurl = "$linkurl";
var lgif = "$linkgif";
var ldesc = "$linkdesc";
function goTo()
[i]/* The following optional javascript conditions detect the absence or presence of affiliate codes, on each clicked code alias. They are needed to detect and complain about ad stripping, or to redirect blank code lines to a message instead of an error page (all are Wizcrafts' added codes):[/i] */

if ( (lurl == "") && (lgif == "") && (ldesc!= "") )
document.write ('<html><body><basefont face="arial, helvetica, sans serif"><h1>Oops! Something went wrong!</h1><h2>The destination codes are missing for this link.</h2><h3>Please turn off your ad blocking program!</h3>')
document.write ('<big>While we may have forgotten to include this destination code in our script, it is more likely that your computer has ad blocking software enabled, which removed the legitimate destination codes from our script.</big>')
document.write ('<p>Please try another link. If the problem persists, and you return to this page, it is probably due to an ad blocking program, such as Norton Internet Security, or McAfee Internet Security, etc. Please turn off your ad blocking program if you wish to view the products we are advertising (whose link you just clicked on). We would greatly appreciate it and you will probably save money on your purchases!</p>')
document.write ("<p>Many people are buying new computers that come equipped with Internet security programs that have an option to block advertising links <u>turned on by default</u>! Somewhere in the program's menus there will be a checkbox to turn off ad blocking.</p>")
document.write ('<p>You can test to see if you have an ad blocking program running by clicking on <a href="http://www.qksrv.net/click-******-*******">this link</a>.<img src="http://www.qksrv.net/image-******-*******" width="1" height="1" border="0" alt="*"></a> It should take you to the (insert advertiser's company name and-or product) page. (Company name) is one of our affiliated sponsors.</p>')
document.write ('<p>If you are transferred to the (Company Name-product page), it means we forgot to fill in some lines of code. However, If you end up back here, you almost certainly have a program that is purposely disabling our affiliate links.</p>')
document.write ('<p>If you were not transferred to the (Company Name) website, you will need to consult the help items for whatever security suite you are running. Search for topics referring to "ad blocking."</p>')
document.write ('<p>If you are not using an ad blocking program and are still <b>not</b> getting redirected to any product page you choose, and keep ending up here, please <a href="/WebmasterContactFormName.html">contact the Webmaster</a> and report the problem. ')
document.write ('Please include the brand and version of your browser, which links failed to redirect, whether you have javascript turned off, and what, if any ad blocking software you are using, in your problem report.</p>')
document.write ('<p>We appreciate your visit and strive to make our website usable and accessible for as many people and technologies as possible.</p>')
document.write ('</body></html>')
return false

if ( (lurl == "") && (lgif == "") && (ldesc == "") )
document.write ('<html><body><basefont face="arial, helvetica, sans serif"><h1>Oops! You clicked on a blank link!</h1><h2>There is no destination filled in yet, for this link</h2><h3>We may have forgotten to include the reference destination code in our ongoing script project.</h3>')
document.write ('<p>Please try another link. If the problem persists, and you keep ending up here, please <a href="/WebmasterContactFormName.html">contact the Webmaster</a> and report the problem. </p>')
document.write ('Please include the brand and version of your browser, which links failed to redirect, whether you have javascript turned off, and what, if any ad blocking software you are using, in your problem report.</p>')
document.write ('<p>We appreciate your visit and strive to make our website usable and accessible for as many people and technologies as possible. Your feedback and problem reports can help us to fine tune our technologies.</p>')
document.write ('</body></html>')
return false

[i]/* The following is the only required javascript code: */[/i]

[b] if (lurl!= "") {
if (!location.replace) {location.href = '$linkurl';}
else {location.replace('$linkurl')}

[b]<META HTTP-EQUIV="Refresh" CONTENT="5;URL=$linkurl">
body {color:#000; background: #fff;}
img {width:1px;height:1px;border:0}
<body onload="goTo();focus()">
<br><br><p align=center>
Please wait a few seconds while we connect to the requested product's page.
<br><br><a href="$linkurl">Click here if your browser doesn't automatically forward you within 10 seconds</a> <img src="$linkgif" alt="*"></p>

sub linkmin {

if ($FORM{'up'} eq 1) {
unless ($FORM{'password'} eq "$adminpass") {
print "$font<center><b>Oops!</b> You must enter your admin password to add, alter, change and delete urls!<br><br><a href=javascript:history.go(-1)>Click here to return and enter your password.</a>";
print LIST "$FORM{'ulinks'}";

@links = <LIST>;

print <<EOF;
$font<center><h1>Dynamic Redirection System 1.1b</h1></center><p>

You may perform the following: (Admin password required to make changes)<br>

<li><b>Adding:</b> To add a new url simply follow this format:<br>
<li><b>Step 1:</b> On a blank line choose a link id followed by a comma.<br><br>
In the interest of keeping things simple we strongly suggest using a number system like 1, 2, 3, etc. However you may use anything so long as it will be unique. <font color=red><b>No two redirection entries may have the same link id.</b></font><br><br>
<li><b>Step 2:</b> Enter the redirection url followed by a comma.<br><br>
Simply copy and paste the url you want the script to send people to for this link id. Make sure you do NOT space between the comma in step one and the redirection url.<br><br>
<li><b>Step 3:</b> You may enter a short description for the link.<br><br>
If desired you may enter a short description for the redirection entry for your records. Do NOT hit enter! All comments must remain on same line and count as one entry. If you choose to enter no comment still leave the comma from step two.<br><br>

Example entries:<br><br>

1,http://www.cyberws.com,Cyberweb Solutions Webpage<br>
3,http://affiliates.auction-genius-course.com/cgi-bin/clickthru.cgi?id=demo,Auction Genius Course Affiliate
<li><b>Step 4:</b> If necessary repeat steps 1-3 to add additional links and when done click on the "Update Links" button.<br><br>
<li><b>Step 5:</b> To use redirection simply send people to:<br><br>

<font color=green>http://www.yourdomain.com/cgi-bin/links.cgi?l=</font><font color=red>link id</font><br><br>

<b>That is a lower case L for link. Remember to change www.yourdomain.com to your own domain name.</b><br><br>

So in our example above we would need to use l=1 or l=2 or l=3. Depending on which url we needed redirection. Now pass this redirection url around the internet, forums, your website, etc. If the link ever changes, like an affiliate link, simply update your redirection link id and boom! No need to worry about dead links or update waste a lot of time update links around the net.
<li><b>Deleting:</b> Simply highlight the line you wish to remove and delete the entry, making sure remove the blank space. Repeat if necessary and then click on the "Update Links" button.<br><br>
<li><b>Update:</b> Simply change the information necessary and click on the "Update Links" button.

<center><hr size=3 width=95% noshade>
<form method=post name="$cginame">
<input type=hidden name=linkmin value=y>
<input type=hidden name=up value=1>
Admin Password: (Required for changes) <input type=password size=30 name=password><br>
<textarea name=ulinks cols=70 rows=20 wrap=off>
print @links;
print <<EOF;
<input type=submit value="Update Links">

<b>To backup links simply download <i>links.txt</i> file - OR -<br>
Copy and save information in textarea in a text document like Word, Notepad, OpenOffice.org, etc</b>


sub parse_form {

my ($pair, @pairs);
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
# Split the name-value pairs
@pairs = split(/&/, $ENV{'QUERY_STRING'});
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
# Get the input
my $buffer;
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);
else {

foreach $pair (@pairs) {
my ($name, $value) = split(/=/, $pair);

$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~ s/<!--(.\n)*-->//g;

# Put form data into variables
if ($FORM{$name} && ($value ne '')) {
$FORM{$name} = "$FORM{$name}, $value";
elsif ($value ne '') {
$FORM{$name} = $value;


I hope this is helpful, albeit a long post.

I anticipate questions and will try to answer them all, to the best of my humble abilites.


[edited by: jatar_k at 11:22 pm (utc) on Aug. 29, 2004]

5:53 pm on Sep 1, 2004 (gmt 0)

10+ Year Member

Hey Y'all!

I should clarify one part of this script, regarding the html code used to call on the cgi script. The "l" in the "/?l= " codes is a lowercase L, not a number one, or capital I. Sometimes those characters all look the same, depending on which font is used by the forum, or your html editor. The cgi script has been written with that as the variable container for the alias. If you change it (the lowercase L) to any other character, without changing the script to match, you will get errors and a failure to execute. If you know your Perl well enuf, feel free to go where no one has gone before, and modify the variable character. But, don't blame me if it doesn't work anymore.


<a href="cgi-bin/links.cgi/?l=99" target="xyz">Product or company description</a>
The l=99 part is a lowercase L, but it is rendered differently on this line, than on the copied code line above!


6:09 pm on Sep 13, 2004 (gmt 0)

10+ Year Member

Interesting thread on one of my scripts. Glad to see people are getting something out of it.

I just wanted to add some comments:

1) I wanted to address some concern over the www.qksrv.net url. There is one way to get around the blocking technology (in most cases). In general most filters look for a domain rather than IP. This is due to the fact that IPs can change. If you go to [netcraft.com...] and type in a URL. You will notice most bigger companies shift IPs every year or so (or even less). Thus the blocking is usually done at the URL level.

So if a URL matches one in the "bad" list it is blocked, rejected, not displayed, etc. This is good news if you are armed with a little knowledge and use a nice "trick". Now the specifics of doing this vary from provider to provider but you need to create a CNAME record.

This CNAME then points to a domain or subdomain.

So CNAME abc.somedomain.com can actually go to www.anotherdomain.com. It is like using cloaking technology but without frames. This fools the blocking technology because it looks like its going to abc.somedomain.com.

If the URL is: www.qksrv.net/click then abc.somedomain.com/click****-*** should work. However having said that sometimes the local server looks for the domain to execute functions. In general this isn't so. We use this "trick" for google to display their ads.

2) Wizcrafts is right about changing the name if you desire. You can also change the text file name. In the cgi script you can modify it to say info.txt or even just info. Just remember to change the actual filename itself.

You may also want to do this so you can run multiple copies for allow for more redirecting URL (at an efficent level) or separate URLs for different reasons.

3) You can edit the script to do whatever is needed. It is possible to modify the script to post extra variables and add them on. I wrote the script aimed at redirecting clickable links. So even if a banner was used the script would come into play when you clicked on the banner. However as you can see Wizcraft wanted something slightly different from the inital script.

That's the great thing about code you can see. You can change it to meet your needs.

4) To answer a question about number of links the script can handle, it is really a matter of what the server can handle.

In theory the limitation would be the max file size the server's OS can handle along with RAM. In most changes several Gigabytes. However that is theory.

In a real world environment the script can handle hundreds of thousands of links, although personally I wouldn't recommend more than 50,000 or so.

Why? Generally flatfiles start to blog down after growing above 3MB when searching for data, hence the entry of SQL databases (along with other reasons).

The orginial write for this script wasn't for people looking to redirect hundreds of thousands of links but rather ten of thousands or under. If one really does need more redirecting units you can install multiple copies or create an interface to MySQL (or another database) using the Perl DBI/DBD interfaces.


Good luck community and enjoy the script. Nice mod Wizcraft. :-)

Long live Perl.



6:17 pm on Sep 13, 2004 (gmt 0)

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

Welcome to WebmasterWorld cyberws
6:26 pm on Sep 13, 2004 (gmt 0)

10+ Year Member

Thank you. Interesting forum you have here, just found it last night. :-)
8:20 pm on Sep 13, 2004 (gmt 0)

10+ Year Member

Thank you very much for your invaluable input regarding the advanced use of your script!
My modifications were specific to CJ affiliates, but could apply to any similar multiple variables redirection.

Would you mind explaining the CNAME usage, for us who are less informed? How is it implemented? It sounds like the equivilant of a URL Alias redirect in .htaccess. Is that what it does?

Welcome to WebmasterWorld and thanks for the great script!

[edited by: jatar_k at 10:10 pm (utc) on Sep. 13, 2004]

9:54 pm on Sep 13, 2004 (gmt 0)

10+ Year Member

No this is not the same. CNAME is something handled at the DNS level usually through BIND. The technology you are talking about .htaccess is handled by the webserver (usually Apache although a few other webservers can handle .htaccess like Zeus).

CNAME is setup either through your web hosting company's control panel or by them or set up through your domain registration company. Of course, this depends on if your domain registration company allows CNAME records. You will have to check.

Another options is to register the domain and then point it to a DNS management service where you can control the CNAME, A, MX, etc records.

You are however correct in you are creating an alias. It is much like an e-mail alias. When someone e-mails an e-mail address they enter somebox@somedomain.com which can be forwarded to say myaccount@myisp.net. The e-mailer is none the wiser as to the true location.

CNAME's are kinda similar in that you create an alias at your domain to point to another domain. It is important to note when creating CNAME's you only duplicate the domain or subdomain.

For example if you want to mask:


You do not create a CNAME for the whole URL. No you create a CNAME record for www.somedomain.com say site1. The full record would read site1.yourdomain.com. Then to call up the image you would:


You see how it works? If the site you are linking to is a subdomain it works no different say:


Then the CNAME would map to ads.somedomain.com instead of www.somedomain.com. Keep in mind that CNAME records names are shared with A, MX, etc records. Thus you can't create a CNAME of mail.yourdomain.com or ftp.yourdomain.com if you are using them for other purposes. Same is true for www.somedomain.com if you are using right now for your main site. CNAME records are specified by typing in the alias only.

So if you wanted site1.yourdomain.com when creating a CNAME you would enter it as site1 because BIND knows to add your domain.

Hope that helps and good luck community.



3:35 pm on Oct 6, 2004 (gmt 0)

10+ Year Member

I have update the script this mod is based off to include one new feature and better programming. The new script should support mod_perl very nicely.

Featured Threads

Hot Threads This Week

Hot Threads This Month