Using PHP to Redirect Affiliate Links
July 3, 2008 · Print This Article
You may have seen many bloggers use redirect pages to send out their affiliate links when people click on their affiliate links. Cloaking your affiliate links to prevent from having your affiliate links hijacked. Your affiliate links can be hijacked. There are malware, virus, etc. out there that many people have on their computers without even knowing that will detect when an affiliate link is clicked and replace your affiliate ID with the hijackers.
First set up a directory on your server for your redirect pages to go. To make it easy I recommend creating a directory simply named “go” (i.e.: www.yoursite.com/go/).
This is how to create redirect page for your affiliate links by using a PHP script.
<html>
<head>
<title>TITLE</title>
<meta http-equiv=”Content-Language” content=”en-us”>
<meta name=”robots” content=”noindex, nofollow”>
<script>window.location=” your affiliate url“;</script>
<meta http-equiv=”refresh” content=”1; url=”your affiliate url“>
</head>
<body>
<p align=”center”>You will be taken to the correct page shortly.
<br>If this page does not load after 5 seconds, please
<a href=”your affiliate url“>click here</a>.</p>
</body>
</html>
Just copy and paste on NotePad and change 3 “your affiliate link” to your affiliate link URL. After that save the file with an easy to remember name that ends with .php. Upload this new file to the “go” folder on your server.Your link will look something like this http://www.gettycash.com/go/tla.php
Whenever someone clicks on your disguised link (http://www.yoursite.com/go/website.php), they are going to be redirected to your real referral link.









Hey,
This is a good solution but once you have hundreds of affiliate links, you’ll have hundreds of files in the go directory. A simpler solution is to create on PHP file to handle all the redirects. This also allows you to track outgoing clicks. See my link above.
Cheers !
Dave