How can one detect the search engine bots using php?
I use the following code which seems to be working fine:
function _bot_detected() { return ( isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider|mediapartners/i', $_SERVER['HTTP_USER_AGENT']) ); }
update 16-06-2017 https://support.google.com/webmasters/answer/1061943?hl=en
added mediapartners
1.4m articles
1.4m replys
5 comments
57.0k users