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. Rip Gill says

    I have affiliate banners on my site in HTML format, and cloak them this way [URL removed – was returning a 404 error]

  2. Huy Nguyen says

    Can I use link.php in subfolder?
    I tried RewriteRule ^go/([/_0-9a-zA-Z-]+)$ components/com_cloakurl/cloakurl.php?id=$1
    but it doesn’t work.

  3. sam says

    Im a non techie. May I know how to clooak click bank affiliate links without a website ?
    I dont understand some of the info online. Is there a simple way to do this ?

  4. Sam says

    Thanks Rosalind for putting together this great post. Finding the best way to cloak your affiliate links is indeed challenging. Especially if you want to track click count or conversions. I ended up using my own redirection subdomain with HTML redirects and some simple PHP code that generates the URL. I then wrote a tutorial for anyone who might be interested:


  5. says

    Thanks for sharing this tip. I was familiar with the old method you described but not the new one. Should make things much easier.

  6. says

    Thank you Rosalind, thanks for sharing this nice helpful trick for cloaking links. As I was using html redirection, and there were almost 78 pages for each link. But now I’ve got the idea of using .php to make those in a single file. Please keep sharing this kind of info. Thank you.

  7. says

    I just ran across a couple wordpress plugins that do the same, wplinkcloaker and eclipse cloaker. Any one ever use them and are they worth the money?

  8. says

    Merci pour l’article, même c’est un peu pas pratique pour les gens qui travail sur des script spécifique. Par exemple pour WordPress il vaut mieux travailler sous une extension, même c’est j’aime pas trop travailler sous une extension (plugin).
    En tous cas merci.

  9. says

    I have seen most people not aware of these link cloaking techniques simple use the tiny.url method or just use a simple url shortener but if many hosting companies would make it easier for noobs to be in the know and learn hwo to do a simple redirect or ghost their links it would make it much harder for other click jackers to steal commish from all of us hard working IM’ers

  10. says

    Nice I tried all the free if you sign up affiliate programs and they all have the same problem, white screen and don’t work and while searching came to your site and nice way to do it. I’m going to give it a go.
    One question that hits my mind and that is. can I use a another domain to put all the affiliate links form all my sites into one file and all the sites would use that domain to call the link instead of the html page the link is sitting on?

  11. says

    Hi. Sorry to be asking you this, but I am not a tech savvy guy and I followed your instructions to the letter. Somehow, I can’t make it work. Any thoughts?

  12. says

    Very awesome method! I’m new to WordPress, and I didn’t wanted to create a WP page named “go” and add sub-pages for every link — what a hassle!

    By the way, the PHP coding wouldn’t work for me until I made some changes. For those of you having trouble, replace the single quotation marks with double quotations ( ‘ to ” ).

    As so:

    “affiliatelink2″ => “”,
    “affiliatelink3″ => “”,
    if (array_key_exists($_GET[“id”], $path))
    header(“Location: ” .$path[$_GET[“id”]]);

    I’m still new to PHP, so I don’t know why single quotation marks were a problem on my site, but things work perfectly now.

    Thanks again, Rosalind.

  13. says

    I just tried to implement cloaking using the steps outlined above. It worked but, when I went back to the site 5 – 10 minutes later to see of everything was working the way it should, I encountered a 404 message. Any idea why this may have happened? Do you have a fix for it?

  14. says

    I’m new to all this and have been using Pretty Links in WP. Reading your article and the following conversation has made me understand why I have been getting the message “ALERT! Your Cloaks and Pretty Bars aren’t working fully anymore.”
    I liked the tracking feature of Pretty Links, but I guess I’m looking for a new method, so might try yours. Thanks

  15. Rick says

    Hi Rosalind,
    This link cloaking via redirect to a php page sounds easy to do for single html links and I would like to thank you for sharing this tip. But how is it possible to redirect affiliate links, that are DHTML, like e.g. a product widget, which includes products from a data feed of the merchant? The script for such widgets are pure php or java script only and all links to images and call to action buttons are generated dynamically. for instance provides such a widget tool.

  16. says

    Hi Roz,

    Your article is more important today than ever, since WP recently canned all WP plugins from its directory that cloak affiliate links. I was using Pretty Links, and when I learned today that the cloaking functionality had to be scrubbed, I remembered your post on your easy method of cloaking affiliate links.

  17. Duncan says

    Most wordpress default .htaccess files look like this

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

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

    does the htaccess code go within the #BEGIN #END wordpress or does it go outside
    like I’ve shown it above ? Also, how can you no-follow these outgoing affiliate links that you will be setting up?

    • Duncan says

      Thanks for the reply Rosalind. That helps.

      I was googling on datafeeder and found this reprint of your bizzites review.

      I hope this guy has syndication permissions from you. Of course when people outrightly swipe your content word for word, your affiliate links will remain but I hate when people post other people’s work without attribution like that.

    • says

      Hi Duncan,

      Thanks for the heads up. Wonder if that’s where all my BizZites sales are coming from these days? LOL
      And no… no one has syndication permission from me. So thanks again.


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

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


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

  21. 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!!

  22. Steve Cotterell says

    Hi Ros

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


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

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



  25. 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?

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

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


  28. 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?



  29. 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?

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