Cloaking/ masking means faking; in affiliate marketing terms, cloaking means hiding your affiliate links. I’ve told you about affiliate tracking links, yeah the links that says you are the one who sent the buyer to your affiliate site; read this post if you don’t know what affiliate marketing is.

Cloaking is required to make sure you get the commission if the customer ever wants to buy the product. Here is what a typical affiliate link looks like,



And some links a even more longer!


Now that’s one reason of cloaking an affiliate link. Affliate links have your affiliate ID and most of the time people will remove your ID. That’s a bad practice; if you want to buy it, why don’t you want to give a cut?

Some people don’t trust these extremely longer links, because they might send them to an untrusted website. Here’s what I did using PHP redirect script,


With a PHP redirect, I can cloak my affiliate links and can keep my ID secure. No one will ever know which link is they are redirected to. Some people uses URL shortening services to do this, but that’s something people won’t like to click.

Here’s how you do it: Create a new text file and open it. Put this code inside the text file,

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: YOUR-AFFILIATE-LINK" );

So that it looks something like this,

cloak affiliate links using PHP script

After that, rename your text file from new-folder.txt to new-folder.php. In my case, I renamed the folder to host-gator.php

Next, you have to create a new folder on your websit’s ROOT directory named ‘go’, ‘partner’ or anything you preffer and then you have to upload the PHP file. After that test your new url and you will be redirected to your affiliate site using your afft link.

By using this method, I got much more click troughs and better results than before.

Blogspot users

Blogger/ blogspot users don’t have the access to their ROOT folder; so in this case you can get a free web hosting account and host your PHP redirect file there.

WordPress plugin

There’s a plugin available on wordpress which can cloak your links easily with a click of a button.

Do you have a better way of cloaking links?

Please do let me know what do you think about this post. Have you ever used affiliate marketing; have used redirect scripts to mask your links? Your valuable comments will be most appreciated.