Affiliate link cloaking is the practice of disguising long, ugly affiliate URLs behind clean, branded links on your own domain. For example, instead of sharing a link like https://affiliateprogram.com/?ref=abc123&tracking=xyz, you would share something like https://yourdomain.com/recommends/product-name.
When I first wrote about link cloaking back in 2008, I showed how to do it manually with .htaccess rules and a simple PHP script. That approach still works, but in 2026, there are much better options available that give you more control, better tracking, and zero coding required.
Why Cloak Affiliate Links?
There are several legitimate reasons to cloak your affiliate links:
- Link management. When an affiliate program changes its URL structure or you switch programs, you only need to update the destination in one place rather than hunting down every instance across your site.
- Click tracking. Most link cloaking tools include built-in analytics so you can see which links are getting clicked, from which pages, and at what rate.
- Cleaner appearance. Branded links look more professional and trustworthy than long affiliate URLs with tracking parameters.
- Protection against commission theft. Cloaked links make it harder for someone to strip your affiliate ID from the URL before purchasing.
Best Link Cloaking Tools in 2026
If you are running a WordPress site, these are the best options:
- ThirstyAffiliates — The most popular WordPress affiliate link management plugin. It lets you create branded links, organize them by category, track clicks, and automatically insert affiliate links into your content based on keywords. The free version covers the basics, and the pro version adds advanced features like geolocation targeting and automatic keyword linking.
- Pretty Links — Another solid WordPress plugin for link cloaking and management. Simple interface, reliable tracking, and easy to set up. Good choice if you want something lightweight.
- Lasso — A newer tool specifically designed for affiliate marketers. Creates cloaked links and also generates attractive product display boxes. More expensive but feature-rich for serious affiliate sites.
If you are not on WordPress, URL shorteners like Replug or branded short domains through services like Rebrandly can accomplish similar goals.
FTC Disclosure Requirements
Here is the critical thing that many affiliate marketers get wrong: cloaking your affiliate links does not exempt you from FTC disclosure requirements. The Federal Trade Commission requires that you clearly and conspicuously disclose your affiliate relationships to your audience, regardless of how the links look.
This means you still need to include statements like “This post contains affiliate links. If you purchase through these links, I may earn a commission at no additional cost to you.” Place this disclosure prominently, ideally near the top of your content and certainly before the first affiliate link.
The FTC has become stricter about enforcement in recent years, and failure to disclose can result in penalties. Cloaking your links is fine. Hiding the fact that they are affiliate links is not.
The Original DIY Approach
For the technically curious, the original method I described in 2008 used Apache's mod_rewrite in .htaccess to redirect URLs matching a pattern like /recommends/product-name to a PHP script that performed the redirect and logged the click. This still works on any Apache-hosted site. But honestly, unless you have a specific reason to avoid plugins, use ThirstyAffiliates or Pretty Links. They do everything the manual approach does, plus a lot more, with zero code.
Bottom Line
Link cloaking is a legitimate and useful practice for affiliate marketers. It keeps your links organized, makes them look professional, and gives you tracking data you need to optimize your content. Just make sure you disclose your affiliate relationships clearly, and you are good to go.




Hmm, interesting approach. Hadn’t thought of it. I’ve just been creating a 1-line php file for each product I recommend. The file contains the true URL and I put it in a directory called “recommends”. Then I just link to that file and it redirects readers to the destination. Looks like the same amount of work, so when comparing it to your method, is there some advantage over the other, or would you say it’s just two ways of doing the same thing?
Thanks, Mark.
Well, I definitely like having all of the links in one file, and I like having the tracking code there. In the end, the result could be similar (assuming you can track with your one-line solution).
Regards,
Mark
I’m only just starting to see the importance of tracking individual links on my sites and actually have a few articles coming up where this may be very useful.
Sometimes it’s better to recommend a product that you believe in and not have you affiliate link shown so that no one thinks you are lying (if that makes sense!!).
Anyway this post has been stored in a safe place for future ref.
Hi
I am new to all this and have been looking to cloak my affiliate links on my website and to be honest i dont think you explain everyhting in laymans terms. I think you presume that people know more. I haven’t got a damn clue what you are talking about.
Hey Phillip.
Your comment made me smile.
I would love to help you get this running. Can you tell me where I lost you? Then we can start from there.
Thanks,
Mark
so, if i were to write an affiliate link such as http://affiliate name here/gajemaster.com I would need to put in recommends before gajemaster and it would cause it to not show gajemaster? Is this correct? I am a bit of a dummy in this area.
No problem. We all start at the beginning. And you are not a dummy if you are smart enough to ask the question.
Let’s say that you have a site that you are blogging on — like this one.
It’s url is http://www.masonworld.com
Now let’s say you want to promote a product that you believe in.
For example, I like Josh Spaulding’s Article Marketing Domination.
So, on my site, the URL for Article Marketing Domination is
http://www.masonworld.com/recommends/amd
In the cloak.php script, I have set up “amd” as an alias for the long affiliate link that you need to use if you want to get a commission selling Josh’s AMD report.
Does that help?
So, in your case, you might want to promote Blog Mastermind.
Instead of your current affiliate link of
http://www.blogmastermind.com/affiliates/index.php?af=820857
You could have something like this
http://gajemaster.com/recommends/blogmastermind
This gives you a clean, more pro look to your links. It also theoretically reduces the temptation for someone to see that you’re promoting an affiliate link and “steal” your commission. The idea is that you are less “in your face” with the link. I have no data to support this claim, but people do argue that.
Hope that helps.
Mark
You are pretty darn good at telling me like it is without making me sound like an idiot.lol. Thanks a heap this really got me to know what I needed to know.
oh, one more question for you. When I write my blog post do I use the affiliate link or do I type in recommends/affiliate name?
That’s why I always tell people that Mark rocks! 😉
@Mark — thanks man.
@Gaje — There are lots of really nice people in the IM niche. If anyone gives you attitude, you should run (do not walk) away.
So, once you get the script installed and working correctly, then I recommend that you always use it. That means that you always use the recommends/product URL in your post.
Just remember to test those links and make sure that you have done it correctly each time (don’t want to miss out on any commissions).
Regards,
Mark
I guess I am missing something here.
I put the line of code in my .htaccess file and uploaded
I created a directory called recommends in my site
I created the cloak.php file with the code you gave us, minus the quotes
I changed the ($request_id, “ed”) and I added a link on a page
When I click on the link I get this…
Parse error: syntax error, unexpected T_STRING in /homepages/28/d95249100/htdocs/findvintagepostcard/cloak.php on line 6
Am I doing this correctly Mark? Maybe it has something to do with…
By the way, make sure that cloak.php has world execute permission, as apache usually has really limited permission to execute files.
I’m not sure how to check this. I have a WordPress 2.6 site.
Mark,
Thanks for emailing me that file. Everything works fine now.
Dennis
Hey Dennis. Looks to me like the .htaccess part is working, but there is some problem with the cloak.php file. If you would like to email me your cloak.php file, I would be happy to take a look.
Hey Dennis. Got your email.
I see funny characters in your file — possibly from cut and paste from the blog. I also see that the path to the cloak.log file is not set in the file that you sent me.
I edited the file and I am emailing your a file that I think might work.
Regards,
Mark
Great news. Glad I could be of service.
Hey Mark,
thanks for the guide on the redirects, works beautifully, and the logging is definitely a plus!
I did however make some minor changes as follows:
For the .htaccess, I made the redirect go to the recommends directory for the cloak.php file, as I like to keep my root folder as clean as possible. It’s also worth noting that some people may need to include the instruction to turn on rewriting if it isnt already done in their file. So my .htaccess looks like:
(/.htaccess)
#You only the next line once, so if it’s in your file already don’t include it again
RewriteEngine On
# cloak affiliate links
RewriteRule ^recommends/([^./]+)$ recommends/cloak.php?req=$1 [L]
Thats the minor htaccess change done, now onto the cloak.php file, which now sits IN the ‘recommends’ directory along with the cloak.log file. I added some comments to your code so it was easier to see what was happening, and I also changed the date format to (YYYY-MM-DD HH:MM:SS) which now includes the time, and is in a format my database can play with at a later stage. My cloak.php now looks like this:
(/recommends/cloak.php)
<?php
$request_id = $_GET[‘req’]; //Get the request string
$myFile = “/PATH/TO/YOUR_SITE/public_html/recommends/cloak.log”; //Set the path to the log file
$refData = $_SERVER[‘HTTP_REFERER’]; //Get Referrer information
$fh = fopen($myFile, ‘a’) or die(“can’t open log file”); //Open the log file for writing
$stringData = date(“Y-m-d H:i:s”).”,”.$request_id.”,”.$refData.”n”; //Concatenate date, request string and referrer information
fwrite($fh, $stringData ); //Write the concatenated data to a new line of the log file
fclose($fh); //Close the file
/*—–Request String Redirections here—–*/
if (strcasecmp ($request_id, “markmason”) == 0) { header( ‘Location: http://www.masonworld.com/‘ );}
if (strcasecmp ($request_id, “google”) == 0) { header( ‘Location: http://www.google.com/‘ );}
if (strcasecmp ($request_id, “docs”) == 0) { header( ‘Location: http://www.google.com/docs‘ ); }
Thats it. Thanks again for the post, and I hope this may help anyone else struggling.
Regards
Vince
You’re absolutely right it’s time to cut it out…