How to Use 301 Redirects to Easily Update Affiliate Links

Here’s a problem I’ve faced a few times in the past: the owners of products I am promoting as an affiliate have changed their affiliate management system.

This always resulted in them issuing new affiliate links, which was a real pain in the butt.

If you’re doing affiliate marketing you have, no doubt, placed your affiliate links in many different places: different blog posts, different social media accounts and probably a dozen other places you’ve forgotten about.

Tracking down all those links and updating them when you’re given a new affiliate link is a real headache and, doubtless, you will miss some.

Today there are plugins for WordPress that ease this problem and, of course, you can use those link shorteners like

But what if you want to keep plugins on your site to a minimum (always a good idea!), or you don’t like those link shorteners because you can’t brand them?

Answer: set up your own affiliate link redirects.

Setting up your own affiliate link redirects allows you to create links that are:

  1. Branded with your domain name
  2. Relevant to the product you’re promoting

The Solution

So here’s the solution (if you prefer watching this process on a video just scroll down – there’s one at the bottom):

For each product you promote create a folder on your server under your domain. You can do this using either the File Manager within your cPanel or an FTP client like FileZilla.

Name that folder with your product’s name or, if necessary, a shortened version of it.

For example if I’m promoting a product called ‘Thesis’ I would create a folder under  called  thesis 

Then, on your computer, create a file called  index.php , and insert the following code:

header("HTTP/1.1 301 Moved Permanently");

Replace the in that code with your real affiliate link, taking care to retain the space after ‘location:’ and the double quotes at the end of the link.

Make sure there are no extra spaces before the initial <? character and after the final ?> character.

Save and close the file, and then upload it to the new directory (folder) you created under your domain name.

Check that everything is working properly by typing in the new URL for your affiliate link:

e.g.:  – this is your new ‘affiliate’ link. Anyone who clicks that link will be re-directed to your true affiliate link.

The two benefits of doing this are:

  1. When the owner of your affiliate product changes their system and requires that you change your affiliate links, you only need to make one change: replace the old affiliate link with the new link in your index.php file within the new folder you created. All clicks on your ‘affiliate link’ will then be automatically re-directed to the new affiliate link the product owner has given you. The time this will save you (let alone the loss of money if you miss some of your links) will be enormous.
  2. Your affiliate links will be branded with your domain name and relevant to the product you’re promoting because you used the product name for your new folder. This will increase your click through rate.

Here’s a video that illustrates the process:

Leave me a comment if I can clarify anything 🙂


Martin Malden

What do you think?

Comments on this entry are closed.

  • Ben Sep 24, 2010 @ 8:07

    I never thought of the reason of just making one change if the link gets info gets changed. That is good.

    I always use 301 just for the look of the link.

    • Martin Sep 25, 2010 @ 7:22

      Ben, hi,

      Yep – you can save yourself a lot of time and lost commissions by only having to change an affiliate link in one place.



  • mike Apr 1, 2011 @ 4:40

    and thanks for this info, but I`m still a little confused with all this, Ive only ever used a wp plugin for cloaking before now and this code stuff is dbl dutch to me, could you make a video explaining this ?

    • Martin Apr 1, 2011 @ 7:15

      Hi Mike,

      Good idea – I’ll see if I can fit that in at some point 🙂