How to detect search engine bots with php?

Asked  Aug 05, 06:30 pm 49 Views Add Your Answer
Asked  Aug 05, 06:30 pm

How can one detect the search engine bots using php?

0 Dislikes
0 Comments

1 Answers

Added  Aug 05, 06:31 pm

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'])
  );
}

0 Likes 0 Dislikes
0 Comments
×
Google login
SignUp with Email
X