How To Hide Affiliate Links

I wrote about hiding affiliate link for better SEO last month. However, the method I wrote about is just one of many ways to hide an affiliate link. I asked Justin from MyPCRig to share a few other ways to hide an affiliate link. This is what he came up with.

As John has mentioned more than a few times on this blog, people are more likely to click on a link if it doesn’t contain an affiliate code. To help you increase your affiliate signup rate, I’ve come up with a list of ways to hide an affiliate link. Keep in mind that there are many ways of doing this. I will be highlighting some of the popular techniques. As always, please read your affiliate program’s TOS and make sure this doesn’t go against it. Some programs have no problems with you hiding an affiliate link while other programs strictly forbid it.


This is a great file to get to know, if you’re using linux. .htaccess is located in the same folder as your index.html or index.php files. If not, you can create one.

Open it up .htaccess and move to the bottom of that file and type this in:

RewriteEngine on
RewriteRule ^john.php$ [R]

“RewriteEngine on” just turns on the mod rewrite program. As you see, will be redirect to John’s website, plus it will contain your affiliate code. This is a very easy way to hide your affiliate code and you just need to edit one file.

HTML Redirect

Another easy way to do hide your code, that doesn’t require a certain OS. Create a file called john.htm and type this in.

<HTML><HEAD><TITLE>Taking you to website</TITLE> <meta
http-equiv="refresh" content="0; url=">
</HEAD> <BODY>Please stand by.</BODY> </HTML>

You just need to create a new HTML file for each of your affiliate program.

PHP Direct

If you have PHP install on your server, then you can use this technique. With
PHP there is a lot of different ways of doing this, but for the time being, I’ll
show you the super easy way.

Create an file called john.php and type this in:


Save it and that’s it. Now will now take you to As with the html way, you will need to upload a new file for each of your affiliates.

Javascript Redirect

This technique will work great on websites, however not in blogs with rss
feeds. Also if a reader turns off javascript, it will take the user to the url it’s
showing. Please note: Google bot has javascript turned off. If the user tries to
open it in a new browser or tab, it will not go to the hidden url.

<a href="" onclick="parent.location.href=’’;
return event.returnValue=false">Mypcrig</a>

These are great ways to increase your affiliate conversions. They might be a
little evil, but it’s a great way to make money online.

54 thoughts on “How To Hide Affiliate Links”

  1. Ed Lau says:

    LOL! Damn that’s evil…but it’s quite true. Most people don’t want to benefit others and are less likely to click on stuff with affiliate codes.

    1. Dave says:

      Very true Ed, some people may even just mouse over the affiliate link,and then type it in to their browser. Stripping out your affiliate code.

      I’ve done that before, when I found a link on a spam site loaded with affiliate advertising and other ads.

      1. I’ve done that before too, by the time I even did not know what an affiliate link was.

  2. Court says:

    Very nice trick. I knew there was a way to do it but I didn’t know that people would click on them more if you did it. I don’t personally care if someone gets paid for recommending a good product to me.

    1. Dave says:

      Yeah I don’t mind affiliate links if the site actually helped me.

      I usually only strip out affiliate code if the advertiser is doing something shady.

  3. DMOZ says:

    Another kick-ass way is to buy mis-spellings of the site. For instance 😈

  4. says:

    Another one would be to use a url forwarding site like

    1. True, however people are starting to catch on to that. Plus a URL from your site is more creditable and more likely be clicked.

  5. Tob says:

    Ahhh… you are missing my favourite link hiding trick of all!

    test link to google

    When they click it instantly changes the HREF to yahoo and also preserves referrer.


    1. DMOZ says:

      I don’t get it…

    2. it didn’t work for me.. nice trick though 😆

  6. Cognoscente says:

    Thanks to Justin and John for the tips. I will have to keep them in mind when it comes time to monetize the site.

  7. Jaxia says:

    Do any of the common programs forbid it? The language of those ToS agreements can be pretty hard to figure out.

  8. blogdinero says:

    thanks john, some times we forget the code

  9. scott says:

    How many times are you going to rehash the same garbage? I haven’t seen a quality post from you in months.

    1. John Chow says:

      How times are you going to ask the same question? I haven’t seen a quality comment from you in months.

      1. troy says:



        1)Regarding aff do you have something for blogger ( ???

        2)Where is harpzon?

        Nice post anyway.

      2. Of course, if people strive to produce quantity, and do it fast, this is what you get. Did you hear about the GIGO effect? Yet, Scott is not right regarding the quality. And he is free to go read something else at any given time, if he’s not happy.

    2. Dave says:

      The solution is simple Scott, stop reading and visiting this blog!

      I don’t know why you’re still coming here if you haven’t seen anything interesting in months.

      What’s up with all the haters lately?

      1. Isn’t that the way it goes? The more successful someone becomes the more likely there will be folks who resent that success. I prefer to admire John for his originality and focus.

    3. you don’t like it … don’t read it. :mrgreen:

      1. At the end of the day, it really is that simple. It’s even easier than changing channels. 😉

  10. very interesting trick, involves some technical-skills 😈 evil!!

  11. Ronaldo says:

    By the way, congrats on the new PageRank, looks like it’s 6 now.

  12. Some good ones here. New 2 me.

  13. Ronaldo says:

    I don’t monetize yet, but I would go with the PHP page.

  14. Jeff Kee says:

    From a web developer’s perspective the header() redirection using PHP sounds like the best one.

  15. Rizal says:

    .htaccess file work to make spider rewrite our url.. :D. add robots.txt too file to the spider will more crazy.. :mrgreen:

  16. Miriguy says:

    I create a HTML file for each of the aff product I m promoting.

    1. Dave says:

      Yes, that’s the method we use too!

      I don’t know if one of these other methods would be more useful though…

  17. Halfdeck says:

    I like this JS better:

    href=”” onmouseover=”this.href=’’;” onclick=”this.href=’’;”

  18. Tyler says:

    Just remember if you are using the header() function in PHP you must make sure you do not have any output to the browser prior to calling it.

    Else it will give you the infamous Headers Already Sent error message which will drive you insane!

    I also like to use exit(); after a header(); because it stops the rest of the script from executing on the server.

  19. When using the PHP version above, don’t forget to include the ? .
    The link should be

    1. oops, thanks for pointing that out. 🙂

  20. Wow, this is sneaky. Very slick though. You can always use the same link and not worry about looking up affiliate code or storing it somewhere. I wonder if this is a bit on the unethical though…hmmm? I guess it is not like they are out any money, they just think they will be directed to a page where you are talking about it.

  21. John – Great post! As a newcomer to WordPress and a hosted environment, I appreciate tips like these. So much great stuff to learn.

  22. hm this is getting a bit too technical for me

  23. will definitely ‘try’ to apply those tips, i was just wondering about that, so that post comes at the right time 🙂

  24. Eric says:

    Great tips, I know that I personally always look to see if someone is profiting off of my ADD clicking. I’ll certainly be using these quality tricks! Thanks John!

  25. it’s good to know, thanks for the tip, john

  26. Technical yes, I always wondered how John did that trick! Now we know!


  27. Ades says:

    Or you could use script called Shorty that I blogged about here. It will shorten long urls as

  28. Mike says:

    If someone clicks on, the landing page becomes

    Is there a fix to that? I don’t want the ?ref=35183 to appear on the landing page.

    2) Also… where can I get a redirection script similar to

    I like the “bar effect”


  29. Wii Skins says:

    excellent! 😈

  30. With my blog i really don’t need to hide the affiliate links because most don’t even know the meaning, because their first concern is fashion.

    Clothing Line

  31. Varun Saxena says:

    Give me the ASP redirect… 😆

  32. Eliot Dill says:

    The first method is certainly the most classy…

    Although nothing groundbreaking…

Comments are closed.