How To Cloak Affiliate Links in 3 Simple Steps

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInPin on Pinterest

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…


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.


header( ‘Location: PUT AFFILIATE URL HERE’ ) ;


The file is now saved at…


Now, whenever someone clicks a link or goes to…


they’ll be redirected to your affiliate url and you’ll get a commission

Pretty cool, right?


Jordan Fried

Hi, I'm Jordan Fried. I'm a 25-year-old American entrepreneur living in Eastern Europe. At 21 I realized the corporate world wasn't for him so I took a leap of faith and quit my job to work on the internet full-time. The risk paid off and it's enabled me to see the world while working from a laptop in some exotic destinations. I'm incredibly grateful to be able to do what I love every day and I want to help as many people as possible do the same.

Click Here to Leave a Comment Below 15 comments
Nate Shivar - August 16, 2012

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).

DeboraHumphries - December 19, 2012

Thank you Jordan for the tutorial. I sincerely appreciate you. I hate depending on plugins, as I want full control. :)

Lemuel - January 3, 2013

Good option for link cloaking, but will it not violate Google’s rule? Thanks. I’ll try this.

marie - April 21, 2013

Just what I’ve been looking for, looks simple enough for a non techie like me. Thanks for the info.

Pam - May 12, 2013

Hello, just wanted to tell you, I enjoyed this post.
It was funny. Keep on posting!

Sam - May 25, 2013

Im a technical idiot. May I know how to clooak clickbank id without a website ? I tried to search info online but most advice given requires one to have a website and is not detail enough on how to do it ?

    Jordan Fried - May 26, 2013

    You can use a URL shortener if you’d like but I’d recommend buying a domain and setting it up using the method I outlined in this post.

    Hope this helps,

Kate - June 13, 2013

Hi Jordan!

I am really struggling with masking. Do you offer a service where I could give you a few links and you mask them for me for a fee? :)

Thank you for your time!


    Jordan Fried - June 25, 2013

    Hi Kate,

    Masking is really not that difficult! Unfortunately I do not offer a service where I mask links for a fee but if you are really having trouble you can go ahead and use a service like http://bit.ly


Angel - August 1, 2013

Pretty cool it is once you learn how it do it! After searching and trying the different methods of cloaking your affiliate links, I find this was the easiest way to learn it!

I don’t know if it was the teacher or the student that made it hard to learn, but thank you for teaching your method!



Leave a Reply: