inversesoft123 Posted July 24, 2010 Share Posted July 24, 2010 I am trying to filter search bots from redirecting to mobile version of website. I am planning to create crawlers array and prevent them to redirect to mobile version of site. function cDetect($USER_AGENT) { $crawlers = array( array('Google', 'Google'), array('msnbot', 'MSN'), array('Rambler', 'Rambler'), array('Yahoo', 'Yahoo') ); foreach ($crawlers as $c) { if (stristr($USER_AGENT, $c[0])) { return($c[1]); } } return false; } //// Now let us work on it $findcrawler = cDetect($_SERVER['HTTP_USER_AGENT']); if ($findcrawler) { }else{ header ("Location: http://m.domain.com/"); } Now when I change user agent of browser with each and every bot user agent and browse the site, code works fine and shows me web version of site and I am happy with that. Now, is it require that search bots must contains "search engine name" in their user agent ? In other words, can google bot crawl my site using another user agent ? Is this a valid way to detect user agents of search bots ? Please guide me. Thanx in advance. Link to comment https://forums.phpfreaks.com/topic/208762-quick-help-google-useragent/ Share on other sites More sharing options...
mentalist Posted July 24, 2010 Share Posted July 24, 2010 Yeah pretty valid... Here's some lists of agents... http://www.robotstxt.org/db.html http://www.botsvsbrowsers.com/ Link to comment https://forums.phpfreaks.com/topic/208762-quick-help-google-useragent/#findComment-1090626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.