Skip to content

Instantly share code, notes, and snippets.

@LeMiira
Created July 21, 2022 10:55
Show Gist options
  • Save LeMiira/f277d89385f24f3771990d71776f10b7 to your computer and use it in GitHub Desktop.
Save LeMiira/f277d89385f24f3771990d71776f10b7 to your computer and use it in GitHub Desktop.
Detect Google Bots
<?php
$remote_add=$_SERVER['REMOTE_ADDR'];
$hostname = gethostbyaddr($remote_add);
$googlebot = 'googlebot.com';
$google = 'google.com';
if (stripos(strrev($hostname), strrev($googlebot)) === 0 or stripos(strrev($hostname),strrev($google)) === 0 )
{
//add your code
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment