Verify Googlebot with PHP
Webmasters maynot be pleased if the content they want to be available to googlebot only is available to any users when they switch their user-agent to Googlebot. But webmaster can easily trackdown this diguised visits.
Here is a simple function in php to verify if the visit claiming to be from Googlebot is a true Googlebot visit.
-
<?php
-
function googleBot()
-
{
-
-
{
-
//robot ip address is assigned to $ipaddress
-
$ipaddress = $_SERVER[‘REMOTE_ADDR’];
-
-
//hostname is assigned to $hostname
-
-
{
-
// returns true if googlebot.com is found in hostname
-
return true;
-
}
-
}
-
return false;
-
}
This function returns boolean true or false and can be used anywhere in your program to show wanted behavior.
The article is based on Verifying Googlebot
Great info. Thanks for the info.