Make It Easy On Your Affiliates With A Hoplink Simplifier

By Robert Plank

If you've managed a web site for a long time then I'm sure you're familiar with custom 404 pages. If a visitor types in the wrong URL or comes to your site through a bad link, you can send a user to a special area.

You can take this a notch up and turn a 404 error into an affiliate program.

This is really useful on a Direct Response Marketing site, where you probably only have a couple of pages anyway.

For example, let's say your site is something like You have a Clickbank affiliate with the ID "joe". Wouldn't it be cool if he could just promote the URL instead of some long and messy Clickbank hoplink?

(I have used this method in the past when I wanted to promote multiple products from one Clickbank account, but didn't want to sign up for a separate account for each one.)

Open up a new text file and place this code in:


RewriteEngine on

# if the request is not a directory, file, or link to another file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

# substitute the "filename" into a clickbank hoplink with you as the affiliate
RewriteRule (^|/)([A-Za-z0-9]+)(/)?$$1/SellerClickbankID [redirect=permanent,last]


The important part: Replace "SellerClickbankID" with your actual Clickbank ID. Save this file as ". htaccess" (with the dot in front) [and no space - Ed.], and upload it to the top level of your web site.

The way this works is really simple. First of all, the URL will only be rewritten if the file that's requested does NOT exist on your site. If the affiliate's name is "joe" and you have a folder named "joe" on your site, that joe folder will be loaded instead of Joe's Clickbank hoplink.

Also, this redirect will only apply if the "filename" (the last part of the file) contains only letters and numbers. That means no periods or anything like that. So if the url loaded was it would work, but would not because for all we know the visitor is looking for a legitimate file. (This is intentional.)

And finally, trailing slashes will work, so if an affiliate promotes (notice the slash at the end) the redirect will still happen. So this behaves as closely as possible to an actual redirect.

Even if you don't use Clickbank as the affiliate program for your product, you can still adapt it to your needs. Take a look at the second part of the last line in that HTACCESS file:$1/SellerClickbankID

The $1 is the place where the affiliate's ID is substituted in. So in this case if the affiliate ID was "joe" and you set your seller ID in the HTACCESS file to "simplephp," the redirect would look like:

And remember, after sending the user to Clickbank they'll be directed right back to your landing page, with the customer cookied in to the affiliate, giving that referrer proper credit for the sale.

Experienced PHP/JavaScript Tutor
Solves 19 Of Your Most Frustrating
Direct Response Sales Page Hang-Ups