I used to cloak my links the old-fashioned way, using simple HTML redirects.
The html page would be coded as follows:
<html>
<head>
<title>YOUR PAGE TITLE</title><meta http-equiv=”refresh” content=”0;url=http://YOUR AFFILIATE URL”>
</head>
<body>
<p>Redirecting, please wait. If you're not redirected within a couple of seconds, click here:<br />
<a href=”http://YOUR AFFILIATE URL”>PRODUCT NAME</a></p>
</body>
</html>
The contents of the page would appear like this:
If you are not redirected within a couple of seconds, click here:
PRODUCT NAME
Then I moved to using PHP redirects, one page for each affiliate link, such as the following which would have been linked from http://yourdomain.com/go/affiliatelink1
Here is the code used for that page:
<?php
header( ‘Location: http://affiliatelink1.com' ) ;
?>
Nowadays, I use a much simpler technique that puts all my affiliate links on one php page, i.e. link.php, which resides in the root directory.
<?php
$path = array(
‘affiliatelink1' =>Â ‘http://affiliatelink1.com',
‘affiliatelink2' =>Â ‘http://affiliatelink1.com',
‘affiliatelink3' =>Â ‘http://affiliatelink1.com',);
if (array_key_exists($_GET[‘id'], $path))
header(‘Location: ‘ .$path[$_GET[‘id']]);
?>
To make the links work, you must add the following to your .htaccess file:
RewriteEngine On
RewriteRule ^go/([/_0-9a-zA-Z-]+)$ link.php?id=$1
The links are then called using the following linking format:
http://yourdomain.com/go/affiliatelink1
Note, you don't have to create a ‘go' folder and you may call it anything you like, i.e. recommends, go, links… whatever.
For example, if youed want to use ‘links' rather than ‘go', then change ^go/ to ^links/
And that's how to cloak your affiliate links the easy way!
Comments, questions or suggestions? Please leave a comment below!
Cheers,
Ros