Affiliate marketing has become very famous lately and many bloggers and online marketers working hard to achieve great success in the field. However, there is a problem that can happen which is affiliate link hijacking so we will discuss in this article how to hide affiliate links and prevent affiliate link hijacking. Affiliate link hijacking is a big issue, some people will change your affiliate URL to their own before buy product so they themselves get paid the commission, giving them a discounted product.

This problem is even worse if you are selling the affiliate product to the affiliate marketers because they can recognize an affiliate link from 10 meters away! They will just substitute your affiliate ID with their own and “hijack” or take your commissions and money.

Some people just completely dislike the idea that you will make a commission from their purchase and will just hack your affiliate ID at the end of the URL. If you don’t take actions to hide your affiliate links from hijackers, then you will continue wasting commissions. Therefore, follow us in this article to learn more how to hide affiliate links using .htaccess, PHP, or in your browser.

Advantages of hiding affiliate links:

  • Decrease affiliate links hijacking.
  • Make URLs look friendlier.

How to hide affiliate links using a redirect PHP script?

This is an easy method to use, all you need to do is build a PHP file that contains a small piece of code, so if you are attempting to promote www-yourID.merchID.hop.clickbank-net then you will create a blank page named, for example –> http://discounts.php that just have the redirect script, so the actual link you promote would be www-yoursite-com/discounts.

Unfortunately, this method does have one disadvantage, some affiliate links will still be visible in the browser address bar, it works great with clickbank.com products.

The simplest way to do it is just to paste this piece of code into a blank web page, and edit it to point to the page you would like to redirect to (which will usually be your affiliate link).

<?php
header( 'Location: http://www.youraffiliatelink.goes.here.com' ) ;
?>

IMPORTANT: This code needs to go directly into your HTML in source view, and it must go to a blank page: There shouldn’t be anything else on that page, not even <html> </html> tags. You also need to save the page as a .php file.

How to hide affiliate links with .htaccess?

Hiding your affiliate links using .htaccess works similarly the same as the previous technique, except you don’t have to use any scripts, you just need to add a line of code to a .htaccess file.

So what do you need to do is to create a new .htaccess file on the root of your public_html directory and add this line:

Redirect /myaffiliate http://www.myaffiliatewebsite.com

The above line means, if you type http://www.yourdomainname.com/myaffiliate it’ll be redirected automatically to www.myaffiliatewebsite.com using 302 Found HTTP Header

But what if you want a 301 Moved Permanently HTTP Header instead of 302 HTTP Header (almost every redirect trick I’ve seen so far is using 302) ? … if that’s what you want … then you can use this

Redirect 301 /myaffiliate http://www.myaffiliatewebsite.com

Unfortunately, this has the same disadvantage as the redirect script method, your affiliate link may still be visible on the merchant’s site in the browser address bar.

Using a frame to cloak or hide affiliate links

This is the cloaking technique that many affiliate marketers use most often to hide affiliate links.

Using cloaking makes it look as if you are sending visitors to a page on YOUR site, even your URL will still be visible in the address bar unlike the above-mentioned methods, visitors will think they are still on your site but they are actually visiting the merchant’s site.

How to hide affiliate links using frames:

You easily create a blank page as above and insert a few lines of code, I also add a title meta tag to fit the description of the product I’m selling.

However, you MUST test your link before promoting it! This technique can affect the tracking on some sites, so be sure that you will be getting credit for all the traffic you send their way.

Here are the steps to manually create the iframe link cloaking code:

  1. Open any HTML editor or a plain blank text file such as notepad.
  2. Embed the following code (as below) but you need to substitute between the <title> and </title> tags the actual text YOU want to be in their browsers title bar and between the <iframe name=…  and  </frame> where it says  src=’  you need to insert the actual link you wish to cloak.
  3. Save it with any filename ending in .htm or .html.
  4. Upload to your server.

– See more at: http://www.freelinkscloaker.com/iframelinkcloaking.htm# IF YOU ARE MANUALLY CREATING THE IFRAME LINK CLOAKING CODE

Here is the code to cloak your affiliate links:

<html>
<head>

<style type=”text/css”>
html { overflow: hidden; } body { border: 0; margin: 0; padding: 0; }
#AffFrame { border: 0; margin: 0; padding: 0; }
</style>

<title>How to Cure Acne Naturally</title>
</head>

<body>

<iframe name=’AffFrame’ id=’AffFrame’ src=’http://b2dbeb1qxdygwfr9vd5qd6e38o.hop.clickbank.net/’
width=’100%’ height=’100%’ scrolling=’no’ frameBorder=’0′>
<p>Your browser does not support iframes.</p>
</iframe>

</body>
</html>

Lastly, I hope you have discovered easy steps on how to hide your affiliate links to prevent your affiliate link hijacking, using .htaccess, PHP, or frames which will surely increase your sales and reduce link hijacking.

Ensure you start to hide your affiliate links so you can ensure that you are not losing affiliate commissions! and protect your site from hijackers so you should make it harder for people to identify an affiliate link to get more commission!

If you like it, share it, please!

You can learn more here about how to get more affiliate commissions. 

More