Friday, March 20, 2009

Simple PHP Google Bot Cloaking Script


This is a really basic cloaking script - it cloaks the googlebot useragent so you can serve one type of content to the google bots, and a different type to your visitors.

OK, so quickly, what is cloaking?

Cloaking is, in a nutshell, serving one piece of content to one person, and another piece of content to someone else, based on predetermined factors.

Despite what Google would have you believe, not all cloaking is evil. Google actually do it themselves when they direct those of us outside the US to our local version of their search engine (google.com.au for me here in Oz)

So why would you want to serve different content to different people? Well, for one, you could serve different content to people living in the US, to what you serve people in Australia, as Google do. Another reason might be to serve different content to people using different browsers (or just send all IE users to a page telling them to get a real browser ;-) )

There are basically (off the top of my head) around half a dozen pieces of information I can get about you when you visit my site:

I can get your browser user agent - this will generally tell me the web browser and version you are using, and your operating system and version..

I can get your IP address

I can get the site you came to mine from.

Based on these three factors, there’s an awful lot of information I have to work with, but those are posts for another day, today, we’re going to talk about cloaking the Googlebot.

Disclaimer - this cloak is not even close to being bulletproof - google is well known to change their user agent, as well as having manual reviewers going over sites with different user agents, so if you intend to play around with this, do it on a domain you don’t care about. If you’re serious about cloaking, you need to get hold of an up-to-date list of bot IP addresses, and they don’t come cheap!

Now on to the code: (When you copy and paste the sript into your text editor, you’ll need to go through and replace all the quotes, wordpress screws them up)

$useragent = $_SERVER['HTTP_USER_AGENT'];

$google = “Googlebot”;

if (strstr($useragent, $google)) {

include(”our-keyword-stuffed-bot-content.php”);

}

else

{

nclude(”the-content-we-want-our-visitors-to-see.php”);

}

?>

Now let’s go through it line by line:

$useragent = $_SERVER['HTTP_USER_AGENT'];
This line gets the user agent string from your visitor

$google = “Googlebot”;
Set the variable $google with the value “Googlebot” (The term “Googlebot” appears in the Google Bot’s user agent string)

if (strstr($useragent, $google)) {
Here we’re using the PHP strstr function to find out whether the user agent contains the string “Googlebot”

Here we place the code we want to execute if the visitor is the Googlebot. You’d place your keyword stuffed content or whatever here. You need to create another file called our-keyword-stuffed-bot-content.php or whatever to be executed here

Here we place our nice looking page that we want our actual, human visitors to see.

So what’s the point of all this?

In theory, you can stuff your our-keyword-stuffed-bot-content.php full of keywords you want to rank for, the bot will see your high keyword density copy, and rank your page accordingly (anybody who says keyword stuffing doesn’t work any more hasn’t tried it recently), then, when actual human people click that high ranking link in the search engine, they will be presented with your the-content-we-want-our-visitors-to-see.php page, which will be a nice page with normal text on it.

I’m sure you can see the potential benefits of this…

0 评论:

Post a Comment

Followers

 

Wordpress autoblog. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com