Using Htaccess To Mask Affiliate Links

by Mike on October 6, 2008
in Affiliate Marketing

One of my readers recently asked me how I mask my affiliate links on my new web hosting review site and I promised I would write up a post about it…so here it is.

There are several different ways to mask affiliate links but personally I use htaccess redirects.  i think its the easiest and most efficient way and I’m going to explain exactly how to do it so you can try it out for yourself.

But first let’s think of a few reasons why you’d want to mask your affiliate links.  Here’s what a typical affiliate link might look like:

http://www.costumecraze.com/WZRD22.html?c=cj,WZRD22

And here’s what it looks like using an htaccess redirect:

/dorothy

Notice they both go to a Dorothy Halloween costume with a merchant I work with through Commission Junction.  The second link has several advantages over the first:

  • It looks nicer.
  • It describes the link destination.
  • Its easier for a visitor to remember or write down.
  • Its more difficult to be hijacked.

Plus, it only takes about 5 seconds to create the redirect.   Here’s how you do it…

Go to your root directory (where your home page is) and look for a file called “.htaccess”.  If its there, open it in Notepad.  If its not there just open a blank document in Notepad and save it as “.htaccess”.  Note there is nothing before the period and be sure to change the “Save as Type” to All Files.

Ok, once its open just go to the very top and enter this simple code…

Redirect /description http://destination.com

Or using my Dorothy costume example above…

Redirect /dorothy http://www.costumecraze.com/WZRD22.html?c=cj,WZRD22

This simply creates a command that tells your server that if someone visits /dorothy they should be redirected to http://www.costumecraze.com/WZRD22.html?c=cj,WZRD22

Piece of cake!  And the beauty is that all of your affiliate links are located on just one text file.  If a merchant changes their links (you eBay affiliates know what I mean) you only have to change one file instead of painstakingly searching through your entire site.

Before I forget, you need to make sure that each redirect is entered on just one line or it won’t work properly.  Also be sure to backup the original htaccess file before making any changes.  Htaccess controls a lot of things and if you mess something up your whole site could be unavailable!

This really just scratches the surface of what you can do with htaccess.  To learn more check out this comprehensive guide to htaccess.

Comments

13 Responses to “Using Htaccess To Mask Affiliate Links”
  1. Dennis Edell (45 comments.) says:

    Just a reader?? Oh sure, no linky love for the D man ;) just teasin…

    OK you opened the can upon my request, now pick up the worms, I got questions…:-)

    1. Mixed feelings – loving the all-in-one factor – not loving the open affiliate link on the address bar itself. I’m not a big fan of “back-spacers”.

    Thoughts?

    2. Possibly a little OT – you mentioned what to do if the document wasn’t already there…..doesn’t every system HAVE TO have one?

    3. In regards to tuerning your computer into a giant paper-weight (lol)…so I can have everything…including what is originally there…all on the one document?

    Totally OT:

    1. Thanks for all the comments! I’ll get to them today :)

    2. The Dorothy costume is nifty, huh :)

    Dennis Edells last blog post..Knowledge Link Love #1: What Are Your Favorite Social Networks and Why?

  2. Paunchiness (1 comments.) says:

    I’m not sure why this is an issue. Most of my links don’t have the whole URL in them they’re just the keywords.
    I understand if you were trying to leave them on someone elses site but on your own it should be pretty simple…Maybe I’m wrong.

    Paunchinesss last blog post..Win an Apple® iPod® Shuffle

  3. Mike Collins says:

    @Dennis: What’s up bud? True, I should have given you some link love for your question…my bad.

    For your follow up questions…

    1. Its pretty late and I’m a little tired from painting my kids’ playroom but I’m not sure what you mean. The aff link isn’t seen in the address bar, just the http://yourdomain/keyword

    2. Most website WILL already have one, especially is you’re using any kind of blog or web design software. But if you’re coding a site yourself from scratch using something like notepad, it might not be there and you’d have to create it. Most people won’t have to worry about that though.

    3. Yup, you only need one htaccess file and you can have thousands of redirects contained in it. The ease of making changes is what I like best.

    PS – yea, that Dorothy costume stood out to me too. lol

  4. Dennis Edell (45 comments.) says:

    LOL I was teasin with the linkage ;)

    1. I click the cloaked link above and get – http://www.costumecraze.com/WZRD22.html?c=cj,WZRD22
    in the address bar….it’s cloaked in the lower left though.

    Excellent info so far :)

    Dennis Edells last blog post..Knowledge Link Love #1: What Are Your Favorite Social Networks and Why?

  5. Yan (12 comments.) says:

    I have always dreaded to go anywhere near .htaccess and for the redirection purpose, I’m using a ‘Redirection’ plugin and I intend to keep it that way.

    Great tutorial, Mike.

    Yan

    Yans last blog post..The Importance of Choosing the Right Niche

  6. Mike Collins says:

    @Dennis: Oh, I see…true the aff link will show up in the address bar. I use it more for link management and hiding it in the lower left.

    @Yan: What kind of plugin are you using?

  7. Yan (12 comments.) says:

    Oh, I’m using this plugin called Redirection.

    Hope it helps for those who are not so tech-savvy..

    Cheers
    Yan

    Yans last blog post..The Importance of Choosing the Right Niche

  8. Dennis Edell (45 comments.) says:

    I’d love it if someone could do an accurate study of how often people backspace through affiliate links (percentage wise)…..I realize this is mostly in the IM field where buyers know what an affiliate link is.

    Thanks for the plugin Yan. :)

    Dennis Edells last blog post..Knowledge Link Love #1: What Are Your Favorite Social Networks and Why?

  9. Simon from Otooo (5 comments.) says:

    Hmmm… I think I might just use the plugin :)
    Sounds easier

    Simon from Otooos last blog post..Best Free WordPress Themes

  10. Sly from SlyVisions dot Com (5 comments.) says:

    This is what I used to do before I bought a WordPress plugin that automated the process. Great tip though. :)

    Sly from SlyVisions dot Coms last blog post..6 Essential Elements Every Blog Must Have

  11. Sly from SlyVisions dot Com (5 comments.) says:

    By the way, there’s also this one plugin called Ninja Affiliate for WordPress that I got. It costs $97, but it’s worth it. I’ll be writing about it on my blog soon, so keep an eye out for it. :)

    Sly from SlyVisions dot Coms last blog post..Got 55 Minutes and 33 Seconds To Spare?

  12. Dennis Edell (45 comments.) says:

    @Sly: Which plugin did you buy?

    Dennis Edells last blog post..Do Advertisers Judge You By Design? What Do You Think…

  13. Mr Javo (3 comments.) says:

    Hi Mike, that’s a great way to do mask your affiliate links, especially to avoid being hijacked.

    I didn’t think about this way before, I do it with a little php script, which you can find in this post:

    http://mrjavo.com/the-importance-of-masking-your-affiliate-links/

    Besides the script, in that post I explain the importance of doing it :) .

    Good post, keep sharing this kind of important information.

    Mr Javos last blog post..How To Make Money Blogging – Facing The Reality

Share Your Thoughts

CommentLuv Enabled