How to Cloak Your Affiliate Links the Easy Way

I used to cloak my links the old-fashioned way, using simple HTML redirects.

The html page would be coded as follows:

<title>YOUR PAGE TITLE</title>

<meta http-equiv=”refresh” content=”0;url=http://YOUR AFFILIATE URL”>
<p>Redirecting, please wait. If you’re not redirected within a couple of seconds, click here:<br />


The contents of the page would appear like this:

If you are not redirected within a couple of seconds, click here:


Then I moved to using PHP redirects, one page for each affiliate link, such as the following which would would have been linked from

Here is the code used to that page:

header( ‘Location:’ ) ;

Nowadays, I use a much simpler technique that puts all my affiliate links on one php page, i.e. link.php, which resides in the root directory.


$path = array(
‘affiliatelink1′ =>  ‘’,
‘affiliatelink2′ =>  ‘’,
‘affiliatelink3′ =>  ‘’,


if (array_key_exists($_GET[‘id’], $path))
header(‘Location: ‘ .$path[$_GET[‘id’]]);

To make the links work, you must add the following to your .htaccess file:

RewriteEngine On
RewriteRule ^go/([/_0-9a-zA-Z-]+)$ link.php?id=$1

The links are then called using the following linking format:

Note, you don’t have to create a ‘go’ folder and you may call it anything you like, i.e. recommends, go, links… whatever.

For example, if youed want to use ‘links’ rather than ‘go’, then change ^go/ to ^links/

And that’s how to cloak your affiliate links the easy way!

Comments, questions or suggestions? Please leave a comment below!



  1. chris says

    Thanx for sharing, im a complete newbie to affiliate marketing i follow some of what your saying, i will have to look more deeply into it, thank you

  2. Simon Croft says

    Hey Ros,

    Never did understand the whole affiliate cloaking stuff. Looks so easy when shown like that. Will have to give it a try.

    Thanks for sharing


  3. says

    Hi Rosalind, very good information. I’ve been using pretty link for about 4 months now, and it’s great. It’s a WP plugin, and it displays all of my affiliates on one page and tracks every click and unique click. I love it.

  4. says

    I have been putting up a page for each redirect and had wondered if there was a way of having them all on one page. You have just made my life that much easier. Thank you so much!!

  5. Steve Cotterell says

    Hi Ros

    I love this idea , and will be implementing it straight away! Thanks for the great tip!


  6. says

    Thanks for sharing this info! This tip has just saved me a ton of effort and helps organize my affiliate links in one place. I appreciate you taking the time to make this info available.

  7. says

    Hey Rosalind,

    I use the html version my self but these other ways give far better looking links.

    Great post will be using the php redirects anymore



  8. says

    I learned how to use a small text file that contains a redirect script and my affiliate link that I name whatever I want and save in my root directory. This cloaks the url but I have to create a text file for each link. Now I am considering purchasing Powerlink Generator because it also allows you to keep track of all the other affiliate information in one place as well (affiliate login, password, commission, etc.) Has anyone used this program?

  9. says

    Hi Rosalind.
    I use a simple html redirect at first but i find the php redirect is much better.
    Or you can use , or similar software to hide your affiliate links.(never use .tk ).

    • says

      Absolutely! If someone sees the affiliate link in the address bar (before clicking on it) they can replace your affiliate id with another one, and you will lose the sale. This is especially true with clickbank A-ids because they are easy to spot. So you have to make sure that your redirect and also cloak it so it doesn’t appear.

  10. says

    Funny, I followed a similar path on my “affiliate redirect journey”. I remember a webmaster clued me in to that “keep it all in 1 file” method, and then when I eventually started coding in PHP, I began implementing that idea.

    One can also take this further if necessary, such as doing any security checks within that 1 master PHP redirect file, choosing 301 vs 302 redirects, email notifications, IP/bot blocking, etc. Yeah, all geeky stuff with possible applications depending on circumstances. But, the basic strategy itself works fine for most people and is a lot “cleaner” than an HTML meta-refresh.


  11. says

    Hi Rosalind,

    I like the new cloaking method you suggest. The PHP redirect I think works well when you only have a few affiliate links, but having to create a page for each affiliate link is a bit time consuming.

    I also use the Pretty Links WP Plugin. All the links are on one page and simply adding the original affiliate link is needed to create the cloaked link.

    Are you familiar with Pretty Link and what are your thoughts on it?



  12. says

    May be not so easy as it seems, for some (or many) of us.

    Could be interesting stuff for a more extensive article…

    Anyhow, it keeps us ‘on track’.

    Thank you!

    P.S. Everything alright with you puppy?

  13. says

    Not being a techie I’m always grateful for this kind of post. I’m still using my old link cloaker which is a bit quicker than manually creating pages.

    All The Best


    • Steven H says


      If it is okay with you, I would like to know your old link cloaker technique. It’s been some time since i’ve used html code(since high school actually) so I’ve been refreshing my mind on html. If you could show me your “quicker” way to cloak the link, I would be really grateful.

      Best Regards,


Leave a Reply

Your email address will not be published. Required fields are marked *

Disclosure: We are compensated for our reviews. Click here for details.