php - Multilingual website - how to detect bots/spiders? -


this question has answer here:

my site changes language according language of user's browser. want bring spinders/bots english-language site (like twitter). http_accept_language of spiders/bots? how detect bots/spiders include file translation in english language? i've seen method of making list of spiders / bots find unsatisfactory. have better solutions?

you can this:

function isspider() {     $spiders = array("googlebot","webcrawler","slurp","msn", "voilabot", "furlbot", "naverbot", "mmcrawler");     $spider_count = 0;     foreach($spiders $val) {         if (preg_match("/$val/i", getenv("http_user_agent"))) {             $spider_count++;         }     }     if ($spider_count!= "0") {         return true;     }         else         {             return false;         } } if (isspider()) {         // set language english } 

you can find list of bot names here: spider names

this assumes bot sets user agent, valid assumption search engines crawlers.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -