Yo there! If you are new here, you may want to subscribe to my RSS feed, or through email, for more tips on better and effective blogging!
If you’ve been an experienced enough blogger, who’s been promoting affiliate links for quite some time, you surely must know the importance of cloaking, or hiding those affiliate links using redirection methods. In case you don’t know why, here are some reasons:
from the http:// to the .com/.net/.org/etc. So it’s everything except your affiliate id. So, they sign up for the program, without you getting your commission. No fair, eh? :(. But by cloaking your affiliate links, those nasty thieves can’t see the original link! And so, they’re forced to click on your link, and you get your commission! WARNING: This method, although helpful, doesn’t cut down 100% on affiliate theft. The hard-nuts still find ways to cheat you of your commission. Can’t do anything about that.
That’s the advantage of using redirections. And I’m about to tell you a 5-minute method for doing so.
So, how do you do redirections? Actually, there are several different methods you can do this. One of them is using Javascript. I wouldn’t recommend javascript since it’s too heavy on size and can cause problems with browsers who don’t have javascript enabled. So, dump this option, I would say.
You can also do this by editing your .htaccess file. But this is a highly delicate and dangerous operation which can wreak havoc(seriously) on your blog if you screw up. Let’s leave that to the experts. Here’s a method everyone can use.
This is the easiest of all the methods to redirect your affiliate links. But make sure that your host supports PHP. If your blog runs on WordPress or MovableType or any PHP based blogging software, you’re cool. And, it’s all done in under 5 minutes(unless you screw something up)
Before we begin, let me tell you what happens:
Normally, an affiliate link looks like this: http://affiliatesite.com/?id=siyab. You can change this to http://yoursite.com/affiliatesite.php. The ‘affiliatesite.php’ is a page on your blog, which contains some PHP code, where you specify the original link, http://affiliatesite.com/?id=siyab in this case. Now whenever someone clicks on the http://yoursite.com/affiliatesite.php link, they are sent to the ‘affiliatesite.php’ page. The PHP code on ‘affiliatesite.php’ then comes into action, redirecting the visitor to http://affiliatesite.com/?id=siyab. And since PHP code is operated on the server itself, no one will be able to see the source code or the original link, thus protecting you to a great degree from affiliate theft.
Note: For the sake of this tutorial, I’ll take this affiliate link http://www.linkworth.com/?a=8168 and set up a redirection page with the address http://www.puttingblogsfirst.com/files/lw.php. Enjoy the tutorial!
Step 1. Get the affiliate link.
The first step is to get the affiliate link. Your affiliate program will provide it to you. For example, my affiliate link for this tutorial will be http://www.linkworth.com/?a=8168.
That’s the first step done.
Step 2. Create a new file with the PHP code in a text editor.
Now, open up a text editor and paste the following PHP code into it and nothing else.:
It all looks like this:

What the above does (crudely) is that it automatically puts your affiliate link in the address bar of the browser and presses the Go button. All this happens within a split second
. That’s as easy as the explanation gets.
That’s 80% of the work done.
Step 3. Name the file and upload to your server.
What you’ve got to do next is to name your PHP file something. Since the affiliate link in question here is that of Linkworth, I’ll name mine lw.php. Remember the .php extension! Also, it’s good if you name it after your affiliate link. But its more of a preference than anything.
After you’ve named and saved the file, it’s now time to upload it to your server. So, fire up an FTP program (or your web based file manager). I suggest FileZilla. Upload your file to anywhere on your server, but I recommend creating a separate folder for all such links, for easier maintenance. For example, I put all my redirected links in to a ‘files‘ folder:

You’re done!
Step 4. Celebrate and use the redirection file!
Now, whenever I want to use my linkworth affiliate link, instead of using the original link, I just have to link to the lw.php file and voila! All done! It also saves me the hassle of having to write out the whole affiliate link while I can simply relatively link to the lw.php file (’/files/lw.php‘ ). Simple and quick!
Some people have reservations about using this method as it’s kind of cheating people. You don’t know what’s at the other end of the redirection file; at least with a whole affiliate link you know where you’ll be going. But a seemingly innocent redirection file can take you anywhere.
The debate is going on since ages. Neither side has had the upper hand for long or at all. I think it all comes down to trust. If you trust the blogger, you can trust him/her not to cheat you out. So, it’s really up to you.
Your turn to speak up: Do you think we should be using redirections?
Note: This post is part of a blog writing contest over at Daily Blog Tips.
For more tips on monetizing your blog, subscribe to the PuttingBlogsFirst feed!
hi my blog is a free blog from blogger ..can i still do the redirection of my affiliate links … how to do it
rob- you can’t use this on blogger blogs since blogger doesnt run on PHP…
I’ve just written a post about doing this using javascript, and that might be useful to you…
That was very useful — and easy. Thanks!
thanks martine! I also posted a 10 second method for doing all this using javascript, if you are interested:
http://www.puttingblogsfirst.com/a-10-second-method-to-redirect-your-affiliate-links-using-javascript/
Which time google update?
For using this you’ve to create one file for each affiliate link. But you can use only one file for all the affiliate link by using GET parameter of PHP and using URL rewriting.
Cheeck this link for detail…
http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html