I don’t use affiliate link directly behind some text, but i used to keep them hidden behind a page in my website, I use a single php file to handle all my affiliate link and let users to navigate into them with a different url structure that looks similar to a page of my blog.

There are many ways to hide affiliate urls, Some peoples apply them directly, Some others use URL shrinkers such as TinyUrl etc.. And someothers use it intelligently in some other ways. I will show you some of them.

One file per link

Some people uses this technique to redirect users to their affiliate link, They use JavaScript, php header / meta refresh etc.. to make this. One of the problem with this trick is, it will make separate files for each link that you want to cloak, this will generate tons of files after some time.

One file for many links

After all miscellaneous stuffs, now we are on the actual area of what this article is about. Redirect to bunch of affiliate links with just one php page ! I am sure this can be done on any servers that running php and Apache.

Anyway the first thing we need to create is a php file to bind all our affiliate links. Take a look at the example template given below.

<?php

// Filename: link.php
// Coded by: Ben Jacob
// E-mail: ben@featherpot.com
// More: http://featherpot.com

/*
http://yourdomain.com/redirect.php?site=company
This example has the same meaning for the other entries in $links variable.
*/

$links = array(

# Product links
      "wordpresstheme" => "https://www.e-junkie.com/ecom/gb.php?ib&aff=321654&ev",
      "blogmastermind" => "http://www.blogmastermind.com/affiliates.php?af=1234567",

# Affiliate Links
      "oiopublisher" => "http://www.oiopublisher.com/ref.php?u=000",
      "textlinkads" => "http://www.text-link-ads.com/?ref=123456",

# Simple sites
      "google" => "http://www.google.com",
      "twitter" => "http://www.twitter.com",
      "myflickr" => "http://www.flickr.com/benjacob/",

      );

# redirection
header("Location:".$links[$_GET['site']]);
exit;

?>
None of the above Affiliate url are real

Don’t understand anything from the above codes ? Don’t worry its simple.. I will explain. All things thats begins with # or // are just comments, ignore them Its beging used for the future. If you comment the codes its easy to modify them in the future without any confusion about the specific snippet.

$links = array (); We are starting a new array of links from this line in the code. each line URLs that placed in separate line will be considered as a new link.

      "google" => "http://www.google.com",

Here the url: http://google.com can be redirected by a single keyword word ‘google’. To add more links to the list you can copy the above template and replace the keyword and url.

The last line is the same header redirect that has been used in the other examples, but instead of hard coding the link in there, it chooses the appropriate definition based on what keyword was passed in the URL.

Now how will you use this file to redirect links by passing keywords ?  Ok, for that consider http://example.com/go/links.php as this file on your server. Just linking to that file will do nothing because you didn’t tell it which keyword to use. If you want it to work, you link to “example.com/go/link.php?title=google”. The file will get “google” as the link variable, look up the redirect link, and perform the correct redirect. The link will navigate you to http://google.com that we have defined in the php file.

Demo

http://featherpot.com/go/link.php?site=google => http://google.com

But that doesn’t look much better than the normal affiliate links you are trying to hide, does it? Well, there is a way to make them look however you want. Stay tuned ..!!