Comments on: Cloaking Links: How To Cloak Affiliate Links for Free https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/ Building Internet Businesses With Affiliate Marketing One Night At A Time Fri, 03 Apr 2026 03:35:58 +0000 hourly 1 https://wordpress.org/?v=6.9.4 By: Charles https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-635 Sun, 29 Nov 2009 18:23:48 +0000 http://www.masonworld.com/?p=185#comment-635 You’re absolutely right it’s time to cut it out…

]]>
By: Vince https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-634 Sat, 21 Feb 2009 21:00:14 +0000 http://www.masonworld.com/?p=185#comment-634 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

]]>
By: Mark Mason https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-633 Fri, 15 Aug 2008 03:09:37 +0000 http://www.masonworld.com/?p=185#comment-633 Great news. Glad I could be of service.

]]>
By: Mark Mason https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-631 Thu, 14 Aug 2008 18:06:32 +0000 http://www.masonworld.com/?p=185#comment-631 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

]]>
By: Mark Mason https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-630 Thu, 14 Aug 2008 16:16:45 +0000 http://www.masonworld.com/?p=185#comment-630 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.

]]>
By: Dennis Guten https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-632 Thu, 14 Aug 2008 15:18:50 +0000 http://www.masonworld.com/?p=185#comment-632 Mark,

Thanks for emailing me that file. Everything works fine now.

Dennis

]]>
By: Dennis Guten https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-629 Thu, 14 Aug 2008 09:27:10 +0000 http://www.masonworld.com/?p=185#comment-629 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.

]]>
By: Mark Mason https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-628 Thu, 14 Aug 2008 04:39:37 +0000 http://www.masonworld.com/?p=185#comment-628 @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

]]>
By: Mark Sierra at MeAndMyDrum.com https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-626 Thu, 14 Aug 2008 04:11:17 +0000 http://www.masonworld.com/?p=185#comment-626 That’s why I always tell people that Mark rocks! 😉

]]>
By: Gaje Master https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-627 Wed, 13 Aug 2008 22:23:30 +0000 http://www.masonworld.com/?p=185#comment-627 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?

]]>
By: Gaje Master https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-625 Wed, 13 Aug 2008 22:08:28 +0000 http://www.masonworld.com/?p=185#comment-625 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.

]]>
By: Mark Mason https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-624 Wed, 13 Aug 2008 19:31:31 +0000 http://www.masonworld.com/?p=185#comment-624 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

]]>
By: Gaje Master https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-623 Wed, 13 Aug 2008 18:31:24 +0000 http://www.masonworld.com/?p=185#comment-623 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.

]]>
By: Mark Mason https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-622 Sat, 19 Jul 2008 04:24:05 +0000 http://www.masonworld.com/?p=185#comment-622 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

]]>
By: philip townsend https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-621 Thu, 17 Jul 2008 13:30:41 +0000 http://www.masonworld.com/?p=185#comment-621 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.

]]>
By: Forest Parks https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-620 Mon, 02 Jun 2008 23:05:24 +0000 http://www.masonworld.com/?p=185#comment-620 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.

]]>
By: Mark Mason https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-619 Fri, 30 May 2008 17:55:29 +0000 http://www.masonworld.com/?p=185#comment-619 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

]]>
By: Mark Sierra at MeAndMyDrum.com https://www.latenightim.com/cloaking-links-how-cloak-links-for-free/#comment-618 Fri, 30 May 2008 12:41:14 +0000 http://www.masonworld.com/?p=185#comment-618 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?

]]>