View Tutorial Metadata Edit Content Revision History Add to Watchlist Add New Tutorial How to detect a specific search engine crawler in PHP

How to detect a specific search engine crawler

To detect a specific search engine crawler on your website you can use the $_SERVER['HTTP_USER_AGENT'] global and the list from http://www.useragentstring.com/pages/All/ in this way :

//example for google bot
if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot")){
    //take action ....
}
 
//example for yahoo! slurp
if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "yahoo! slurp")){
    //take action ....
}

Only plain text supported.

Optional

Required - will be kept private

Optional

 
 

Rating: (0+, 0-) In: PHP 5