How to Make Those Long Ugly Affiliate Links Look Good

A disguise mask for a fancy dress ballA while ago I wrote an article explaining how non-techie types who don’t have their own website can disguise their affiliate links when they’re posting them on Facebook (or any social network) – you can read it here.

This article looks at how you can disguise them if you do have your own website on your own domain and server.

Why would you want to disguise your affiliate link?

Surely you want your affiliate link clearly spelt out so people can be sure of typing it in correctly, right..?

For sure you want people to transpose it accurately – but disguising it is probably the best way of making sure that happens.

Many companies’ affiliate links are long and unwieldy – many contain numbers and parameters, for example 

And that gets worse if they start adding country codes in as well.

Ideally, you want a link that you can print on business cards or publish online that’s simple, clear and easy for people to remember.

And the biggest benefit is that, once you’ve created a human-friendly link, your real affiliate link will never be mis-typed again because it will be coded into your human-friendly one.

So here’s what you do:

Step 1: set up a new folder (directory)

Go to your File Manager, or log in via FTP, and create a new folder in the root directory.

On many servers it will need to sit in the ‘public_html’ directory but, if your hosting provider has set things up differently, it may be called ‘httpdocs’ or something similar. In any event, set it up in the same folder that contains your site files.

Give this folder a name that’s relevant to your business. Some programs don’t allow you to use the business name (or company name) in URLs, so check with your company if necessary. If you can’t use your company name use the chief benefit the product offers, or anything else that’s relevant, as the folder name. But keep it short!

You now have a new but empty folder in your root directory

Step 2: create an index.php file

Next you need to create an index.php file that will contain your real affiliate link and the code that will re-direct visitors to your company page.

Copy the code below and paste it into a text file:

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

Make sure there are no spaces before or after any of that code!

Replace the  in that code with your own real affiliate link, starting with http://. Make sure you retain the closing double-quotes.

Save the file as  index.php  (Windows users will need to select ‘all files’ as the file type).

Step 3: upload your index.php file

Using either your File Manager or FTP, upload your index.php file to the new folder you created in step 1.

Step 4: test your new link

Your new affiliate link will now be in this format: . Remember to choose a short name for the folder you set up in step 1.

Test the link to make sure it works!

As long as you followed the steps above carefully everything should be fine, but if you’re experiencing a problem here are some things to check:

  1. Open the index.php file on your computer and check that you’ve inserted your affiliate link correctly
  2. Check that there are no spaces at the beginning or end of the code
  3. Check that there are no extra characters inserted into the code (Word will do this). If there are, use an application like Notepad++ to highlight the characters so you can remove them
  4. Make sure that the only characters you changed in the code above was your affiliate link itself. All other punctuation marks (double quotes, semi-colons) must remain in place.

If all those things check out and you still have a problem copy the entire contents of your index.php file, paste it into the contact form and send it to me.


Setting up a user-friendly folder for your affiliate link like this not only makes it easier for people to remember, it also ensures that your affiliate link is never mis-typed.

That’s because it’s coded into your human-friendly link.

But there’s an even more useful application of this process: if you want to send people to specific pages on your company site – e.g. a specific product page – you can use the same process to create another folder but, instead of inserting your general affiliate link in the index.php file, you can insert the specific page link (which must, of course, contain your affiliate ID).

Those specific page links are invariably long and complicated and using this process enables you to make them short and simple. This is a good way of getting people straight to a product page where they can buy without getting distracted along the way.

Any questions, leave a comment – and I’d be eternally grateful if you shared this page through one of the buttons below..!


Martin Malden