Hide Affiliate Links with PHP

  • Posted By: Tarik
  • 2 Comments... What do you have to say?

When marketers sign up for an affiliate program, you are provided with special affiliate tracking links to keep track of your referrals & manage your earnings.

Most affiliate programs equip affiliate marketers with the following type of tracking URLs:

Example: SEObook.com
Affiliate Link = http://www.seobook.com/2496.html

The subfolder contains unique tracking codes that send data back to SEObook’s database to monitor how much traffic you’re sending. You will always use this link to promote SEObook, but this is not the proper way to present links to your visitors.

Redirecting your visitors from a sub-directory with PHP is the safest and most efficient way to promote and earn commissions from your affiliate relationships.

Why You Should Hide/Cloak Affiliate Links

Masking affiliate links protects both the affiliate and website visitor for a number of reasons:

  1. Prevents search engine spiders from penalizing websites with complex affiliate links & traffic codes.
  2. Insures you receive credit for informing visitors of a helpful product or service. If you took the time to inform your visitors of a wonderful resource, then you deserve credit for the hat-tip.
  3. Maintains root domain consistency within your website, and safely guides visitors to external resources.
  4. Places all affiliate links under 1 easy to maintain sub-directory for future maintenance. Affiliate managers alter affiliate links all the time.

How to Create a Simple PHP Redirect

A simple PHP redirect will allow you to link to any product you’re promoting without revealing the URL source.

  1. Grab your affiliate code, and open up your FTP access to create a new subfolder under your domain.
  2. Choose a simple name for the folder like “recommends” or “reviews” or whatever. I personally use “r” currently to limit the length of the URLs.
  3. Create a PHP file called “productname.php” and enter the following code:
    <?php
    header (’location: AFFILIATE LINK GOES HERE’);
    ?>
  4. Save the folder, then upload it to your subdirectory.

Now when you want to send traffic to your affiliates, simply link to the PHP file you just created.

You could even create a MySQL database to track clicks, use a custom link cloaking program to handle everything for you, or code a custom PHP script for all your affiliate links. Your options as an affiliate are endless!

So How do you hide your affiliate links?

Download Your Free Report on How to Create a Profitable Website or Blog!

  1. Faraz Ahmed said on May 19th, 2009 at 6:52 am

    This method does not work.. I got this error:

    “Parse error: syntax error, unexpected ‘:’ in /home/****/public_html/buynow/productname.php on line 2″

  2. Faraz Ahmed said on May 19th, 2009 at 7:42 am

    I found a better method that works.. here it is: http://www.associatedcontent.com/article/25128/how_to_hide_affiliate_program_links.html

What do you think? Join the discussion...

How do I change my avatar?

Go to gravatar.com and upload your preferred avatar.