How To Cloak Affiliate Links in 3 Simple Steps
Recently I learned a simple and cool way to Cloak Affiliate Links.
Those of you who have experience with affiliate marketing already know what an affiliate link looks like.
For those of you who don’t, they look a little something like this…
www.companyname.com/1101/affiliateID
The problem here isn’t just that affiliate URLS are ugly. Affiliate links also have low click conversions rates compared to cloaked affiliate links.
So, here’s how you cloak an affiliate link in 3 simple steps
1. Create a folder in your HTML directory
This should be something like http://yourdomain.com/recommends/ or http://yourdomain.com/likes/
2. Create a folder within the folder
This folder should be named after the company you’ll be promoting. Let’s say you became an affiliate of Honda and you’re going to promote Honda products (don’t think Honda really has an affiliate program but let’s just use this as an example). We already created a folder called “recommends” and now we’re creating a new folder within our “recommends” folder named “honda.”
3. Create an index.php file and save it in the company folder
Create an index.php file and put the code below in the file. Put your affiliate link in the appropriate place.
<?php
header( ‘Location: PUT AFFILIATE URL HERE’ ) ;
?>
The file is now saved at…
http://yourdomain.com/recommends/honda/index.php
Now, whenever someone clicks a link or goes to…
http://yourdomain.com/recommends/honda/
they’ll be redirected to your affiliate url and you’ll get a commission
Pretty cool, right?






Pretty neat to know the behind the scenes. I’ve always used plugins like SimpleURL on my WordPress sites – which I believe just does exactly what you describe (url/go/affiliate).
Thanks Nate! I thought it was interesting myself and I’m glad I shared it!
Thank you Jordan for the tutorial. I sincerely appreciate you. I hate depending on plugins, as I want full control.
Thanks for commenting Debora – much appreciated
Good option for link cloaking, but will it not violate Google’s rule? Thanks. I’ll try this.
I dont see why this would violate Google’s terms. Curious to know what rules you think this would violate.
Hi Jordan, the codes will give a 302 redirect and Google seems to favor the 301 redirect, but perhaps it will depend on how you use it. But if you want to make it a 301 redirect, just insert header(“HTTP/1.1 301 Moved Permanently”); right after <?php I'm actually familiar with the process but haven't used it because I was comfortable using a plugin. But since I upgraded to WP 3.5 the plugin I used became obsolete, so I decided to apply this manual process.
Quoting Google Webmaster ( http://support.google.com/webmasters/bin/answer.py?hl=en&answer=66356 ):
“Note that PPC (pay-per-click) advertising links that don’t pass PageRank to the buyer of the ad do not violate our guidelines. You can prevent PageRank from passing in several ways, such as:
- Adding a rel=”nofollow” attribute to the tag
- Redirecting the links to an intermediate page that is blocked from search engines with a robots.txt file “
Just what I’ve been looking for, looks simple enough for a non techie like me. Thanks for the info.