Website Cloaking Script
I have been doing a lot of affiliate marketing lately and one of my biggest concerns is always protecting my landing page from competitors. Since I’m tracking every visitor that comes to my landing page, I can get a good idea of how many of those visits are competitors looking for ideas for their sites. I can’t really blame them, I check up on my competitors as well. This doesn’t mean I don’t attempt to protect myself.
With the help of Ben from WickedFire.com I put together a short script that will cloak your site from anyone not coming from the exact sources you specify. You can even white list IP addresses to make sure no direct traffic comes to the site that doesn’t belong there. Be careful with that one since you might be sending away actual customers. I always redirect to the offer page just to be certain.
So, here is the script:
<?php
if(!empty($_SERVER['HTTP_REFERER'])) {
$referer = parse_url($_SERVER['HTTP_REFERER']);
preg_match(‘/[^.]+\.[^.]+$/’, $referer['host'], $match);
if ($match[0] != ‘trafficsource.com’) {
header(“Location: http://www.offerpage.com”); //redirect all traffic that comes from any source except the one listed above
exit;
}
}
if(empty($_SERVER['HTTP_REFERER'])) {
$visitor = $_SERVER['REMOTE_ADDR'];
if (!(preg_match(“/xx.xxx.xxx.xx/”,$visitor)) && !(preg_match(“/yy.yyy.yyy.yy/”,$visitor))) {
header(‘Location: http://www.offerpage.com?subid=directTraffic’); //redirect all IP addresses to this that are not the IP addresses listed above
exit;
}
}
?>
This should do the trick. Remember to fill out the correct information in the script, it won’t “just work.” One last thing to remember is that when you enter a traffic source, it should be the root domain (myspace.com, google.com, facebook.com) and nothing else. The script will parse the referring source down to just the root domain. You can add as many IP addresses as you want just by adding another AND (&&) operator. You can also tweak this code to cloak your site anyway you want. Hope you enjoy!





Twitter Me!