How To: Using .htaccess to Cloak Affiliate Links
July 7th, 2008
In August of last year I explained how to hide your affiliate links, which received some good feedback. That post is my preferred method, as it uses PHP redirects to cloak the affiliate link and allows me to upload a single file to multiple websites.
The drawback of this method is that these can still sometimes look like affiliate links. If you’d prefer to have better looking affiliate links (though it requires extra work to setup), this method is probably better for you.
Here are the steps that you need to cloak your affiliate links using your .htaccess file:
- Access your .htaccess file.
- Type the following:
redirect 301 /french-toast http://YourFrenchToastAffiliateUrl
That is it! On this site, this would take the URL of slickaffiliate.com/french-toast and redirect the user to http://YourFrenchToastAffiliateURL.











I may seem dumb but could you write a little bit about what .htaccess really is because I don’t know much about it.
@ Michael – Consider me in the “no question is dumb” camp. It might be hard to explain, but if you dig through the root directory of your WordPress install you should see an .htaccess file. This is sort of your websites directory and allows you to quickly and easily make website configuration changes.
I’m a little slow this evening. Are you saying that for every redirect we need to have:
redirect 301 /link1
http://link1_affiliate_link_here
redirect 301 /link2
http://link2_affiliate_link_here
And so on?
@ Mark – It should look like this:
redirect 301 /link2.com http://link2_affiliate_link_here.com
I think it looks the way you have it above due to the advertisement making it wrap. Just put a space between them and it should work, all on one line.
To me cloaking should be transparent so you only sees one link and same resulting link. For example, if your link is /mylink and affiliate link is http://affiliate_link.com, you should only see /mylink and once clicked on it your destination is to http://affiliate_link.com, but on address bar it still shows /mylink. So your affiliate link is never displayed.
Redirection will show your link before clicking it then shows affiliate link after clicking it. Like those phishing emails that you get, contains link that shows eBay, PayPal or some bank, but once you click it takes you to some foreign site trying to steal your identity. I think some people might find it phishy.
Here’s another article about it: http://pcshare.com/Website-Design/117-Faulty-Article-on-Link-Cloaking.html