How To Manually Cloak Affiliate Links Using PHP Redirect

Internet marketers and bloggers live and breathe affiliate links, weaving them into their content here and there, trying to make them look appealing. The best way to make your affiliate links looks good is to cloak them. This means that instead of having ugly links with all the tracking numbers exposed, you can manually cloak affiliate links by using PHP redirect. Of course there are plugins that do this for you, like Ninja Affiliate ($1 trial at the moment) or Thirsty Affiliates.. They are both great plugins but if you like doing things yourself then creating PHP redirects is not that hard.

Manually Cloak Affiliate Links Using PHP Redirect

To cloak affiliate links manually using PHP redirect you will need access to your server. This is only possible if you have your own paid for web hosting and will not work on free blogs.

1. Logon to your server. Go into the root of your domain.

2. Create a new folder. Name it as you want the link to appear. For example, if you want the link to be tips4pc.com/PcMatic then you would call the folder PcMatic.

3. You can also put the PcMatic folder in another folder like tips4pc.com/go/PcMatic. This just means you make a folder named GO in the root, then go into that folder and make another folder called PcMatic.This way you do not have to overcrowd your root domain with new folders. You can put all of the affiliate folders into one neat folder.

4. When you are in the PcMatic folder, click on the create file icon and name the new file index.php.

5. Paste the code shown below into the file and save it. Make sure you replace my affiliate link with yours.

<?php
header( ‘Location: http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=Mitzpantic‘ ) ;
?>

Replace the purple link text with your own affiliate link.

Video – How to Manually Cloak Affiliate Links

It is much better to cloak your affiliate links because here is a perfect example why:

Uncloaked Link: http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=Mitzpantic-

Cloaked Link: http://letsbuildwebsites.com/Hostgator

Extra Tips

  • It is good to nofollow your affiliate links so you are not passing on Page rank to them. Also because http://letsbuildwebsites.com/Hostgator page does not really exist so you don’t want this to be indexed.

Comments

  1. Nikhil says

    when I was created my PHP redirecting affiliate link I got an below error –

    Parse error: syntax error, unexpected ‘:’Parse error: syntax error, unexpected ‘:’ in /home1/ramesh/public_html/buy/index.php on line 2

    I have checked my code 3 to 4 times as per your video but couln’t solve my problem. Will you please help me.

    • says

      You must have an error there. Please copy the red text in my article…paste it into a notepad…then add your url into that. Now use that clean text to create the index.php code.

  2. says

    I actually use custom affiliate links and they don’t look too bad on my blog so I don’t really have much of an issue with this.

  3. Suzie says

    Hello,

    Interisting post. For WordPress I’m using now the “Redirection”, just search for it in the plugin install box and you’ll find it. It also logs everything, which is also nice for your click stats…
    Suzie recently posted..Vodafone V1415

  4. Erik says

    Hello,

    I followed your directions exactly, however when I try to go to the link at the end i’m getting this error message on the website:

    Parse error: syntax error, unexpected ‘:’ in /home/madupz/public_html/recommends/index.php on line 2

    What do you think the problem is?

    Thanks,

    • mitz says

      Just doublecheck the url which is your link and the actual code you pasted into the index.php. There must be an error.

  5. John K Lemieux says

    i use plugins when I work in wordpress, everything has a plugin for it. But its good to know we can do this manually.
    John K Lemieux recently posted..Eyes Slider

    • Mitz says

      This is the same. You only edit one link and it changes all your previous redirects. Of course it is easy to use a plugin too! I try not to use too many plugins that your site will rely on. Especially when it comes to making money. I had a plugin I had to take out and it took me days to redo my links. While this was going on I lost sales.

  6. Vektor says

    Firs thing i said when i saw your post title is “WOW”. I have been while searching everywhere to know how can i clock my affiliate links , and here you are guiding me. Thanks alot.

    • mitz says

      This is exactly why i use the product name in the url so people know what link they are clicking on. It also says this in the article. it looks better than 3hdof333.395je.com ??? At least with a product name they know where the link will lead.

  7. says

    hi Mitz.
    It is best idea. I have read this article, It is very informative. I like it.
    i will use the php code to my wordpress

  8. says

    I actually use custom affiliate links and they don’t look too bad on my blog so I don’t really have much of an issue with this.

  9. Stan says

    Hi Mitz,
    PcMatic is a great tool and this video confirms it. Cloaked addresses look more user-friendly.

    • Mitz says

      I agree Stan!! PCMatic is a great tool and cloaking looks better to the visitors. I also like to “nofollow” these links so google does not think there are pages that exist for these links.

  10. Richard says

    A nice little php trick that just works :)
    I can think of a few things to use this for.

    Thanks Mitz!

  11. John Will says

    Hi Mitz!
    Great article.I was looking to try it for my webiste and it’s really a big help.Now i think it would surely help me getting click on my affiliate links.

  12. Glen says

    Great video! I haven’t tried cloaking yet but it looks so easy that I would have to keep my hands busy of the weekend because of this! thanks!

  13. Dedicated PHP Programmer says

    Wow! Amazing post! Great use of PHP! I didn’t know about this before…Thanks for sharing!

  14. Greg says

    Mitz, awesome tip!! So much better than using htaccess or link shorteners.

    Question regarding these links…any way to track when/number of clicks?

  15. SEO news says

    Miz this post is really good, I was also having trouble with affiliate links and wanted to cloak as search engines especially Google is having problem with affiliate links. My site is built with WordPress and I finally get figured it out.

  16. says

    This is a pretty neat way to mask affiliate links. I actually use custom affiliate links and they don’t look too bad on my blog so I don’t really have much of an issue with this. However if I start using other affiliate links I might need to cloak to make my blog look decent.

  17. Vic says

    I´m wondering if this is the solution I was looking for to get more clicks on my affiliate links!!! this tutorial has helped me do it manually…cheers mate

  18. Annetta Powell says

    Hi Mitz,

    Found your blog through your guest post in comluv.

    I am not an affiliate marketer but mostly a network marketer. But I do affiliate marketing as well. Since I have several sites hosted in the same hosting account, if I do php redirect, is it going to screw up the other sites? I really don’t deal with the hosting account as I have someone managing it. I think I should go for the Ninja plugin to make it easier.
    Annetta Powell recently posted..Network Marketing Scams – Fact Check List

    • mitz says

      I agree the plugins make it easy also..but the redirects are placed in the root of the different domains so they wont mess with each other.

  19. says

    Hi Mitz,
    It is a nice article I have gone through ,I am not used cloaked Affiliate Links manually though I owned a web site design a web hosting site so far. But I will surely opt the guideline you have shown. Thanks again

  20. D.J. Maak says

    Hey Mitz,

    This is always a great thing to know and the method I prefer using for my links. I’ve never seen the point in investing in a plugin to do it when it’s pretty simple to do it by yourself. Also by doing it this way, you only ever have to change one link if your affiliate link changes rather than going through all your posts and changing all your links if you were to use affiliate links straight up.
    D.J. Maak recently posted..Michael Fiore Text Your Ex Back 2.0 System Launches

  21. says

    A very useful trick! I was actually looking for a way to cloak affiliate links on my blog and I was considering getting the plug-ins to do this. I’ll try you way and see how it goes. Thanks for sharing Mitz!

  22. Nawaz says

    Hi Mitlz

    Good tutorial but I think one should be master of PHP to get benefit from this tutorial.

  23. Aditya says

    Hey Mitz,What a timing Mitz…I have been looking for this from morning but couldn’t do cloaking,my developer ssaid he will soon find the solution but thanks to you.You are a savior :)
    Aditya recently posted..ERP Software India

Letsbuildwebsites.com runs on the Genesis Framework

Genesis Theme Framework for WordPress

When I changed to the Genesis Framework and the eleven40 Theme my page load score went from 58 to 79 instantly. This was without any optimization at all. The other thing about this framework and theme is that it was so simple to setup that I can highly recommend it to each and every person that visits this blog! Genesis is the smart choice for your WordPress website or blog.