DYDAS Professional Website Design

How To Cloak Affiliate Links & Why You Should

By on November 5, 2007

Masking or cloaking affiliate links is an important step you should take when adding links to your websites or blogs. This practice of redirecting your affiliate links can be accomplished through .htaccess instructions, meta refresh tag or a simple PHP script.

Benefits of Cloaking Affiliate Links

  • Makes it easier for yourself to remember and share your links.
  • Website visitors place more trust in links which use your own domain name.
  • Search Engines will not penalize you for selling text links.
  • Easily maintain & update all of your affiliate links in one file.
  • Increase click through rates and revenue earnings.

I am going to briefly instruct you on how to get started cloaking your affiliate links using a simple PHP script and code snippet placed in your .htaccess file.

How To Cloak Affiliate Links

Affiliate LinkClick here to copy my simple affiliate link cloaking script. There you will see my ID names and URLs to various resources that I recommend. Feel free to visit them! Copy and paste the code into a text file and name it “link.php.” It is a very straight forward script that I am confident you will have no problems modifying for your own use.

Once you upload the script to your web server you can start using it by updating your links to this format:


Go a step further and include this snippet of code into your .htaccess file:

RewriteEngine On
RewriteRule ^link/([/_0-9a-zA-Z-]+)$ link.php?id=$1

*Note* This may not work with WordPress due to conflicting rewrite rules.

Now format your links as sub-directories like so:

The entire process is seamless to your website visitors and easy to implement! Hope you enjoyed this tutorial. Please leave a comment if you have any questions or suggestions.


About Mark Fulton

Mark is the Founder of DotSauce Magazine and a full time web developer, domain investor, SEO and online marketing professional residing in North Carolina, USA. Visit MarkFulton.com for information on freelance website development, SEO and consultation services.