16th Hide your affiliate links using .htaccess file

I’ve been searching for a method to hide the affiliate link for months. If you are long involve in the affiliate programs then hiding affiliate links might just a simple daily routine work. Please let me know if you have a better idea. The best method that I found so far is by using .htaccess file to redirect your affiliate link. For example, you have an affiliate links that looks like below:


You can redirect the above link using the URL below:


That means you will be using the new URL for the link instead of the old affiliate link. Your visitors will only be shown by the new URL. When they click on the new URL, they will be redirect to the old affiliate link or the destination you wanted. All you need to do is place 2 simple lines into your .htaccess file.

RewriteEngine on

RewriteRule ^sample.php$ http://www.affiliate.com/join.html?refer=123456 [R]

You can place it at the bottom of the file. If you have another affiliate link that you need to add, just repeat the above steps. Replace sample.php with another name that you like and change the affiliate link. Then add the 2 new lines at the bottom.

P/S: Check out this post on how to access your .htaccess file.



Both comments and pings are currently closed.

28 Responses to “16th Hide your affiliate links using .htaccess file”

  1. esvl says:

    I was wondering how people do that. Great info

  2. Matt Ellsworth says:

    nice idea. I usually just make a file for each thing and load the site in an iframe. But this idea seems a little easier.

    Could you do this in a subfolder as well – so that you don’t increase the size of your main .htaccess too much?

  3. Jason - Blogging4cash says:

    This is a nice idea. Im sure there may also be some link redirect plugins somewhere for wordpress.

  4. INconstantIN says:

    Thank you for the idea:)!

    OffTopic: For how long have you been displaying the “Buy this ad” from 125box.com? Did you have any advertisers interested in publishing any ads on your blog?

  5. Jason - Blogging4cash says:

    Here is what you need I think.

  6. Kumo says:

    I’m not sure about doing this in a sub folder. Haven’t try that before.

    As for the 125box ads, I’ve been using it for a week. I did have some advertisers coming in but it seems that the service is not that good. Not sure if it is the advertisers call back the ads or there is problem putting up the ads. Still trying to figure this out.

  7. Kumo says:

    Great info Jason. I’ll check it out.

  8. Jason - Blogging4cash says:

    I found a updated version here: http://www.bizquarium.com/friendly-affiliate-links

    And I have tested it out and works ok. Only thing is I have to go in a re-edit all my post. check my seobook or pepperjam post to see it in action so far.

  9. webtoks says:

    Hey Kumo- Thanks for “touching” my blog. Can you shed some light on the issues you had with 125box?

  10. Kumo says:

    Well, at this moment I still haven’t see any ads up on the 125box. I approved one ads for 125box but did not see it appeared on my blog. I check back and it stated “reject” on my account. Some feedbacks have been send to 125box. I’m still not clear with the situation at this moment. As 125box is still very new, I give it some time to do their work. I’ll continue to evaluate the out come and their work progress. 125box needs to respond and work fast as there are many compatitors for this type of advertisement. There are few other advertisement that I like to try and time is almost up for 125box.

  11. webtoks says:

    Hm.. Very strange. Why would they reject an ad you approved? Technically, it should be the other way around. Meaning they approve an ad(because the more ads they approve the better for them) while you reject the ad based on its relevance or whatever reasons you deem fit.

  12. Kumo says:

    That’s right. That’s one strange point about it. For now 125box takes up 50% of what you get. So just this reason is enough for me to get rid of it later.

  13. Eric says:

    That’s one way,

    but you can also do it with some easy php code and some functions.
    Do a search for: header(“location…

    A few tweaks will make it work like a charm 😉

  14. Kumo says:

    Thanks for the info Eric.

  15. SEO News says:

    What about using tinyurl.com ? I’ve heard people use that to hide their affiliate links as well. Or is that the other direction only?

  16. Kumo says:

    Thanks for the info. As long as it can hide the affiliate links then it’s consider fine with me. I’ve just check tinyurl.com and seems to me it’s a good tool. I noticed a lot of sites using the same kind of URL and did not realize about it. Thanks for sharing.

  17. Navin says:

    I really hate clicking links which actually takes me somewhere else.
    It’s a very unethical way of advertising and fooling your own visitors.. They shall know where they’re been redirected.
    These tricks could actually forward people to malicious sites.

    I think lots of AD companies are against this particular issue. They want people to see their referral as well.

    Or may be I’m being much concerned.

    Whatever, I don’t like sites which fools people to click on their link

  18. Kumo says:

    That actually depends on how the services are being used.

  19. zee says:

    I think thats a great idea. I previously had used tinyurl however this isnt professional. I’ll try this and hopefully it will work.

  20. Kumo says:

    The idea of this method is to hide your affiliate id so that you’ll get the credits.

  21. cloaking says:

    I use URL Shortening Service for my blogger blog since i can edit .htaccess file.

  22. Kumo says:

    Good for you.

  23. This is really the information that I was looking for. Thank goodness you shared it with us… Way to go.

  24. Wordpress_Newbie says:

    Hello, i tried the steps to hide my links but it doesn´t work.
    Do I have to create the sample.php file? Do I have to change something at my wordpress too?
    My htaccess has the following entries:

    # BEGIN WordPress

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

    # END WordPress
    AddType x-mapp-php5 .php
    AddHandler x-mapp-php5 .php

    RewriteEngine on

    RewriteRule ^sample.php$ http://link.to.hide [R]

    Thanks for help.

  25. Kumo says:

    Delete second “RewriteEngine on”. Only need to write it once. Move “RewriteRule ^sample.php$ http://link.to.hide [R]” right below “RewriteRule . /index.php [L]”. I hope this helps.

  26. Wordpress_Newbie says:

    Hi Kumo,
    no it doesn´t work 🙁
    Maybe I forgot one step which is quite natural for you??
    I only have to change the htaccess? No changes at worpress or do I have to create a sample.php file or folder?
    Thank you.

  27. Kumo says:

    There are couple of things you can try out. First is to upgrade to the latest WordPress and try it again. Second is that you can try simplified your .htaccess. Perhaps use the default or original .htaccess and work from there. Hopes this helps.

    P/S: just wondering if you use http://sample.php or http://www.yourdomain.com/sample.php? Should be using the second URL.

  28. Kavita says:

    Thanks for info. I was looking for code to add to .htaccess to hide php extension of redirected affiliate.php url