HowTo: Hide Affiliate Links on WordPress Blogs

HowTo: Hide Affiliate Links

Affiliate marketing is one of the many ways blogs and bloggers generate income. I’m sure most of you, especially those who have blogs are familiar with this because some of you are also members of affiliate programs and have affiliate links across your blogs. Here on JaypeeOnline, I also have several affiliate banners and links which mostly are for premium WordPress themes.

So what’s wrong with affiliate links and why do we have to hide them? The problem with most affiliate links is that they’re ugly, too long, and are suspicious-looking to most blog readers or visitors. Here’s an example:

Wouldn’t it be nice and look better if the link was something like this:

The idea of hiding or “cloaking” these affiliate links is to make blog readers think that the affiliate link is an internal URL or a part of the current blog. When a blog reader or visitor thinks that it is an internal link on your blog rather than a third-party site, that person is more likely to click on the “cloaked” link than the normal affiliate link. Another benefit of “cloaking” or hiding affiliate links is that all our blog links point to an internal address on the domain and it also makes it more convenient for the blogger to update the affiliate links and avoid having dead links when the company updates or changes its affiliate links. Hiding affiliate links can also improve your conversion rate and an improved conversion rate can mean an increase in affiliate earnings.

There are several ways of hiding affiliate links, one is by using online services that shorten URLs like TinyURL or, another method is using javascript to change the URL’s text displayed on the status bar or installing WordPress plugins but most of them are not free. If you don’t want to spend extra cash just to hide your affiliate links and would want to do it yourself or want to avoid using a plugin, then this tutorial is for you. This tutorial uses PHP redirects which involve only a few steps and is quite easy to follow.


  • FTP client and FTP access to your webserver
  • Text editor (if you don’t have one, you can get one from here or here)


  • Create a folder on your blog’s root folder or public_html directory named “go”. (You can use a different name if you want)
  • Create a blank PHP document using a text editor. (Use the same name with an affiliate link to avoid confusion) ex. GoDaddy – godaddy.php
  • Copy and paste the following code into the blank PHP document: Affiliate Link Code
    (Replace http://youraffiliatelink with the actual affiliate link)
  • Save the file and upload it to the “go” folder created in Step 1

That’s it! You now have “cloaked” your affiliate link. In case you need to create several PHP redirects for different affiliate links, just follow and repeat the steps listed above making sure that you name the PHP document with the same name as the affiliate link so you won’t get confused.

Your affiliate link redirect will look something like this:

I hope this simple tutorial has helped you improve your affiliate links and make them easier to manage without having to purchase a WordPress plugin and also help you improve your conversion rate and affiliate earnings. If you need assistance in creating the PHP redirects and setting it up on your blog, feel free to contact me or leave a comment on this post and I’ll do my best to help you.

This post may contain affiliate links that allow us to earn commissions at no additional cost to you. We are reader-supported so when you buy through the affiliate links, you are also helping or supporting us. 


  1. Hi Jaypee, Thanks for the post. I was looking for this information. My blog is hosted on godaddy and just now cloaked my godaddy affiliate url.

  2. TheCaymanHostsays:

    Whilst I realize this post was made a fairly long time ago I thought I’s add a few updates that might be helpful. I’ve written extensively about cloaking and redirect methods on my blog for anyone wanting more detailed information.

    TinyURL has been abused by spammers and as a result many applications including browsers such as Chrome reveal to the visitor the destination URL to help them avoid being send to a porn site or some other nasty places they may not wish to visit. Chrome actually directs visitors to an ugly preview page before they get to your site – this will guarantee the loss of visitors. So, for affiliate links it’s pretty dead in the water if you are trying to mask a link.

    Someone mentioned frames – cloaking using frames was once a good method but ceased to be a long time ago. IE for example will block cookies from domains other than that shown in the browser address bar – result, you lose more commissions than you protect! The visitor gets to your site but your cookie stands zero chance and you make nada, zip, nothing. IE’s standard privacy settings are something most people will never change and as the majority of web users still use the crappy MS browser you should never use frames unless you only want to sell to Firefox users ;-)

    I realize your method here is a straight PHP redirect – this is not a problem for cookie setting but…it is not very secure and more often than not the raw affiliate link will still appear in the browser address bar. If you want to track your links as well, this method falls short too and it’s more time consuming than it needs to be. Also, a growing problem is parasite software – I explain this on my blog too if you want more information but basically a PHP redirect is vulnerable to such trickery too.

    There are so many options for cloaking links and this is already turning into a blog post as opposed to a comment. However, there is a lot of bad information out there on this topic, a lot of software that can do more harm than good too, but there are some little jewels as well and whilst there is still no perfect way to guarantee that all your affiliate links will be correctly tracked to you, there are ways to maximize your chances. A quick search for link cloaking on my blog will lead you to some revealing information not often found if any of your readership are interested.

    Maurice TCH

  3. Does this mean I have to change all the links in all my posts? I have over 200 posts and I wish not to back to my old posts.

  4. @SGDNetworks – Thanks for the compliment! Regarding your question, yes you’ll have to create individual php files for each unique product. For the example you used, if you have 10 PC Tools products, what you can do is create a file called pctools1, pctools2, etc. It can be a bit tidious but it will work.

    Also if you think this is too much work, you can try Get Shorty which is discussed several times in the comments. I haven’t tried it myself but I think it requires less work.

    Hope this helps. Let me know what method you decided to use with your affiliate links. Have a nice day! :)

  5. Hi Jaypee,

    Thanks for the nice post. But i have a doubt like if i have 100’s of urls’ then? for example i wish to promote products, it have about 10 products. So i need to create 10 product php pages with each proper product affiliate link right?

    Please clarify me.


  6. @Film-Book – Thank you! Get Shorty is not a WordPress plugin. It’s a third party program that you’ll have to install yourself. You can get it from here:

    Thanks for sharing those links from John Chow. I’m sure someone will find those useful too. It would be good to have you around here. Have a nice day! :)

  7. Nice post Jaypee. I haven’t been here in awhile.

    Is Get Shorty a WordPress plugin? Where can I get it?

    I found these other methods for hiding affiliate links a while ago. I thought you readers would enjoy them as well. The first method is very similar to yours. Chow modifies it so he can track clicks on those in Google Analytics. Very cool.

    I’ll be on your site more often so look out. :)

  8. @Alwin – Thanks for sharing! Although, there’s one problem with your method which is the use of frames. Why? Because frames violate many web standards.

    Frames don’t work well on all browsers especially on mobile devices. Also, if you rely on search engine traffic using frames is a big problem because search engines have problems reading frameset pages.

  9. How about the Mod rewrite method? Haven’t tried it, though :-) I’m using a PHP click counter script to hide my affiliate links.

  10. @Pavel – You’re welcome and thanks for dropping by! Your blog is now one of my favorite blogs and daily reads. :)

    Btw, I tried visiting your blog the other day and I kept getting a page can’t be displayed message. Well it seems that its working fine now but just wanna let you know. Happy Holidays!

  11. @Fitz – Using tinyurl or other link shortening services is also another option, however your links become “artificial” and becomes a bit suspicious looking to some readers/visitors.

    I’m not sure if I can consider myself into heavy affiliate marketing but I agree with what you said. Its good to disclose that you have affiliate links on your blog. I haven’t really thought about that and might consider doing that here. Thanks for sharing and pointing that out! :)

  12. @joie – You could’ve asked me about it. Then I would’ve helped you or made this tutorial earlier. Next time you need help with something, just let me know, ok? You’re welcome! ;)

  13. I actually just use tinyurl to make my affiliate links “prettier”.

    Anyway, when you are into heavy affiliate marketing, I think it’s better to disclose to your readers that they are affiliate links and most, if not all, of the time – they don’t really lose anything from using your affiliate links.

  14. Finally, I was wondering when are you going to make a tutorial for that. I did get the idea of redirecting the affiliate URL from internal file using php from your site. It took me a while to figure out how did you do it, but after sometime of reading php tutorials i manage to redirect my affiliate links using the same method as yours. Still, thanks for sharing..

  15. @iRonnie – Hi there! Long time no see here. Hehe anyways, thanks for sharing about Get Shorty. I’ll have to try that one of these days and maybe write a part two of this tutorial using Get Shorty. :D

  16. hi jaypee. i installed and currently using Get Shorty to get the job done. you might want to try it instead. No need to access your FTP. :D

Leave a Reply

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