How To Mask Your Affiliate Links Using PHP
NOTE: If you are not comfortable playing around with code and want a very simple solution to link masking try Easy Link Manager for a very low cost solution.
People stealing your commissions is never cool!
This post is going to walk you through a really neat way of preventing this from happening using a small piece of PHP code.
Let me quickly show you what the end result looks like.
www.fmsseo.com/recommends/KeywordElite
Now doesn’t that link look professional when you compare it with the free link masking URLs.
URL masking using the PHP code method allows you to retain a very nice clean and professional URL and remind others of your website when you post the link on external sites (such as Squidoo and HubPages etc).
To use this method you will need a domain name and you can get one real cheap over at NameCheap.com.
You will also need a hosting account and one of the providers I continually recommend is HostMonster.com.
For this method you will need to create a folder within your selected domain and name it ‘recommends’ (or something else that you choose) as shown in the screenshot below. You can do this directly in your FTP software or on your desktop.
1. Right click on your desktop and
2. Select ‘Folder’.
Name the folder ‘recommends‘ or something else that you wish to use.
Now you’ll need to open up notepad and type the following code exactly as it is shown below.
Save the document by clicking on ‘File‘ and selecting ‘Save As‘.
Now name the file ‘index.php‘ shown below (1) and choose ‘All Files‘ as shown (2).
All you need now is the URL you wish to mask and the name of the URL string that you want to add to the end of your cloaked URL.
For this example, I created another folder inside the ‘recommends‘ folder and named it ‘KeywordElite‘.
1. Recommends Folder
2. Name the folder after the affiliate product (in this case Keyword Elite)
Now, reopen the index.php file you created (and hopefully saved somewhere easy to find such as your desktop).
You’ll need to add the URL that you wish to mask.
Below you can see the code with the URL included that I am going to mask.
Save this again as index.php but make sure you select the KeywordElite folder (or the folder for the URL you are masking).
You’re nearly finished.
All you have to do now is make sure that you upload the folder to your hosting account using an FTP client.
You’ll need to place the ‘recommends‘ folder in the root directory.
Follow these steps again for each new affiliate program that you are recommending. Please note: any letter after the main domain is case sensitive, so if you save the folder a ‘Recommends‘ with an upper case R then that is how you must write it down when you create a link on your blog, website, report etc.
This is, for me, the ultimate way to mask your affiliate URL. If you would like to make this even more powerful then I recommend you take a look at Easy Link Manager.
You’ve now discovered how to save your affiliate commissions from being hijacked while promoting professional looking affiliate links.
How do you mask your affiliate links?
To your success,
Karl Foxley
NOTE: Commission hijacking can be done in many ways, in the same way computers can be infected with malware and viruses (search on Google or visit popular affiliate marketing forums and you’ll find lots of information). It can be as simple as you using free software to mask your links and then the site owner (or a hacker) running a script to change all affiliate tags to their own affiliate ID. An affiliate link is an affiliate link no matter what it looks like and a redirection should NOT be used to dupe a visitor.
25 Comments
Trackbacks/Pingbacks
- PhilBellamyInc - How To Mask Your Affiliate Links Using PHP - http://bit.ly/4naxVR
- 10 Blogging Tips That Improve Your Blog - [...] How To Mask Your Affiliate Links Using PHP – FMSSEO This post is going to walk you through a ...
- 20 Blogging Tips and Tools for New Bloggers - [...] How to Mask Your Affiliate Links Using PHP – FMS SEO [...]
- Alltop SEO - How To Mask Your Affiliate Links Using PHP http://bit.ly/6dOVGD SEO.alltop.com








Thanks for pointing out this technique.
By the way, when you refer to commission hijacking, you’re referring to when, if you leave a comment on a blog with an embedded affiliate link that the blog owner would change the affiliate link to his own?
.-= Digitivity @ The Digital Life & Tools Blog´s amazing last blog ..How to Claim Your Blog on Technorati =-.
That is not commission hijacking because dropping your affiliate links on to people’s sites is just VERY bad practice.
Nice article on hiding those links. going to have to do the recommends folder instead of what I’m doing now. Thanks for the heads up.
Larry
.-= The Niche Think Tank´s amazing last blog ..31 Days to build a better blog =-.
I never even thought of that as ‘commission jacking’, but that’s exactly what that is! Thanks for sharing your wisdom on the matter
I’m glad you’ve found the guide useful Dasche.
This article looks very interesting and clean.
For bloggers who are using WordPress: Just use Ninja Affiliate or Gocodes to mask your affiliate links ^_^
Thanks for nice post!
Hi Toan,
Those plugins are great but what happens if they stop being supported or they conflict with another plugin and start breaking your site?
With just knowing this option you can reduce the need for another plugin, always a good thing.
Thanks for taking the time to visit and leave a comment.
Karl
Thank you for sharing this nice information.
.-= chandan´s amazing last blog ..Sponsored tweets- great work at home opportunity =-.
You’re welcome Chandan.
will it be possible to do this with a sub-domain blog?
.-= murkcore´s amazing last blog ..The Storm, Picturesque – Hours (2009) – Progressive Metalcore/Hardcore =-.
Hi Murk,
If you own the sub domain then yes as you will need access to the server.
Karl
Hi Karl,
You have shared a very useful information needed for bloggers. apart from Easy Link Manager is there any other tool?
.-= Deepika´s amazing last blog ..SEO – True Story =-.
Hi Deepika. The cheapest one on the market, but still very good at what it does, is PHP Link Cloaker.
Hope that helps,
Karl
Does this work with the plugins out there like ninja affiliate or separate?
Hey Dennis, I have GoCodes on my server running from the /go/ folder and I use the PHP method above from the /recommends/ folder so I can’t see any problems with using this alongside any dedicated software.
Example:
http://www.fmsseo.com/go/elite
and
http://www.fmsseo.com/recommends/KeywordElite
Hope that helps,
Karl
Perhaps a post of the GO system then…do they do anything special for ya, etc…
I wrote about GoCodes WordPress plugin here http://www.fmsseo.com/222/affiliate-link-masking-wordpress-plugin/
RT @extremejohn: RT @karlfoxley: How To Mask Your Affiliate Links Using PHP http://bit.ly/8tCp5L
RT @karlfoxley: How To Mask Your Affiliate Links Using PHP http://bit.ly/8tCp5L
I have been looking for something like this for our MMA blog, woot! Thank you, Sunday Smash bound.
.-= Extreme John´s amazing last blog ..10 Reasons I Wouldn’t Copy Your Article =-.
That’s awesome John.
I always thought that the programming behind link masking is very complicated. Thanks, you made it look very simple.
I’m heading over to Easy Link Manager and see if they have a trial version, so I could check out how good it really is.
.-= James M.´s amazing last blog ..Track Cell Phone =-.
Easy Link Manager is a great little tool and is quite a bit cheaper than PowerLinkGenerator.
I agree, you made it very simple, I could never have thought about this!
.-= Hesham @ FamousBloggers´s amazing last blog ..How to add more URLs to your CommentLuv plugin account? =-.
Thanks Hesham.