In this post I went over the cool free link cloaking script by Andy Fletcher. For those who don’t want to use a script you can easily cloak your links using a PHP re-direct file.
You don’t have to know squat about PHP programming since it’s just three lines of code and all you need to do is enter the affiliate link you want to cloak.
Here is the code:
<?php
header(“Location: http://www.affiliate-link-here.com”);
?>
All you need to do is open up notepad, copy and paste the code above into your text editor like notepad then save it as a php file and upload it to your server. When you link to that file, they’ll be redirected to your affiliate link.
It will only take you a few minutes to cloak your links following the steps above.
Here is a video tutorial I shot which walks you through the process.




Hi Alan
Thanks for cloaking affiliate tips.
This tips helps me a lot to hide my affiliate links.
Do you have to have a different link cloak for each affiliate program you want to use?
Hi Robert,
Yes, I cloak all my affiliate links. I’m now using a WordPress plugin called Simple Link Manager which is awesome. It’s not for sale yet but if you’re Teli Adlam’s customer you can get the SLM plugin for free.
Hi Alan
Do you cloak affiliate links from cj?
Which method do you use to cloack cj’s aff link?
In spite of the fact that she no longer sells Optiniche. It is great if you have purchased Optiniche as she has always coming up with something that makes blogging easier.I consider it one of my better purchases. So yes I have obtained SLM and am wending my way through it.
Hi Edy,
Yes, I cloak all my affiliate links including CJ. It won’t include the 1×1 tracking image but (in my opinion)you don’t need it.
I agree Robert. I purchased Optiniche almost two years ago and it’s on my best purchases. Teli is amazing.
Alan, cj links contain url and image. When I choose individual product and get the html code. Cj said that I must include all the code including image source to track properly.
I still confuse how to cloak cj’s link.
Right now I am using freelinkcloaker from andy. And I can’t cloak cj’s link using freelinkcloaker. Is it possible to use php redirect to cloak cj’s link?
[...] left an excellent question in the php re-direction post comments. I was going to respond via the comments section but my [...]
Hi Edy,
My response was getting too large and this is a great topic so I wrote it’s own post about it:
http://www.imnirvana.com/affiliate-link-cloaking-cj-links-with-php-re-direct-file
I hope that clarifies things a bit.
Where will the php file will go in the server. Thanks
On your server create a new directory by creating a new folder–call it whatever you want but popular choices include: “Recommends”, “Like”, and “Go”. Once you’ve created your directory for example “Recommends” put your files in that folder and the redirection will work. And your URL will look like this: yoursitename.com/Recommends/productname
Whatever I do, the redirect code will not work.
I have created the php file in Dreamweaver. Then, in the Notepad. Removed the arguments, and tried the root domain ( .net vs .net/?affiliate=, etc)
Never works, but just shows the code on the page, and complaints about errors on the line with the header function.
Any suggestions?
Thanks in advance.
I’m not sure what you mean with removing the arguments. Here is what to do…
1. open notepad
2. paste in the code:
< ?phpheader(“Location: URL”);
?>
3. Replace “URL” with the full url (doesn’t matter if it’s .com, .net, .info, etc.)
4. Save the text file as “index.php”
5. Create a directory in your hosting account called “recommends” or whatever you want to name it.
6. Inside the “recommends” directory create a directory using the SEO friendly naming convention of the link. For example: “product_name”
7. FTP the text fie you created “index.php” into the “recommends/product_name” directory.
That’s it. Now when someone clicks on yoururl.com/recommends/product_name they will be redirected to the URL in the index.php file. Make sure you don’t have any spaces or missing anything from the code since even a blank space can create a problem.
Thank you so much for the step by step guide you provided in response to a question by one of your readers (no name attached to the post).
I had the same problem and had followed instructions to the letter even watching your video on how to do it tons of times but the re-direction link won’t work…. not untill I saved the script as index.php
Everyone says save it as .php but nobody mentioned the index bit. I have to say though that i have seen files saved as .php and has worked. I have even saved a php redirect file like that in the past and it worked. That is why I was so baffled that it does not work for me this time.
I don’t understand these things very much but all i know is my redirection is working fine now with index.php
May be you could explain why .php works sometimes for some people and other times you have to save with index.php.
In any case thanks. I have wasted a whole day on this but was determined to find the solution. In the end my patience paid off by discovering your website.
Keep up the good work
Peter
(struggling online but will succeed)