Best way to hide and cloak your affiliate links?

One may first think of using JavaScript to do this by dynamically changing the windows status bar URL, but unfortunately this trick doesn’t work across Firefox browsers.

The truth is the visitor or clicker will eventually find out that they’ve been referred to the affiliate merchant by you from the ultimate landing URL — sometimes this may be totally redirected to the clean home page of the merchant, but many’s the time it’s not.

So the one thing you can make sure is the reader of your site must click through your affiliate link to get to the merchant. And the following snippet will help you achieve this. Start a index.php file and put this in:


In which is your referral link. Save this file somewhere in your domain such as /go/example. The next time you want hide and cloak the real affiliate URL, or at least make it look more neat, just point your readers to /go/example and they will be automatically redirected to the affiliate link.

Another good way – via Javascript, to hide or cloak the status bar URL

Another way of doing this is to rely on JavaScript for changing the href property of the a tag when the visitor clicks on the affliate link:

<a onclick="javascript:document.location='';return false;" rel="nofollow" href="">Example</a>

The potential problem of this approach is that if the visitor browser’s Javascript capabilities are turned off, you will not be credited for your referral because they will be using the plain href link.

10 thoughts on “Best way to hide and cloak your affiliate links?”

  1. So I have tried adding a php file as well as certain cloaking plugins and they work so-so, however what if you have multiple affiliate programs/product links what do you recommend? Making multiple php files seems not to be the best answer?? Wondering if there is an easier way that is just as clean? Thanks 🙂

    1. You should be able to support multiple affiliate links by creating one directory with one PHP file.

      Here is how you can do it.

      You will need to be using an Apache server with mod_rewrite enabled for this to work. You will also need to be able to alter Apache settings with an htaccess file.

      First, create your directory. Call it “go”.

      Next, within this directory, save a new .htaccess file. The file contents are as follows:

      Options +FollowSymlinksRewriteEngine on
      RewriteRule ^([a-z0-9_-]+)$ index.php?token=$1 [L,NC]

      These settings will allow you to use a URL such as /go/amazon, and it will be rewritten to index.php as index.php?token=amazon.

      Next, in your index.php file, you can add multiple redirects based on the token which is passed in. Example:


      switch ( $_REQUEST['token'] ) {
      case 'amazon':
      $redirect = '';
      case 'amazon2':
      $redirect = '';

      if ( isset($redirect) ) {
      header("Location: {$redirect}");
      } else {
      header("HTTP/1.0 404 Not Found");

      Just place a “token” at the end of the URL (eg. /go/token). Then make sure there is a case statement for it (case ‘token’:), and set $redirect to the real affiliate link (surrounded by single quotes).

  2. Pingback: How to hide and force the visitor to click your referral or affiliate link?

  3. you could also use onmouseover of the “a” and change the status of the link

    I think it is a good idea to use your own redirect script in case you have to change your aff ID for some reason

    1. Yeah that would do. I use my affiliate id on many sites so if I could use a redirect script, when my affiliate id or the merchant affiliate structure changes, all I have to is to make one change and it’s all fixed.

Comments are closed.

Scroll to Top