最新消息: 新版网站上线了!!!

php仅让搜索引擎访问的方法

 $tmp = $_SERVER['HTTP_USER_AGENT'];
 $false = 0;
if(strpos($tmp, 'Googlebot') !== false){
    $false = 1;
} else if(strpos($tmp, 'Baiduspider') !== false){
     $false = 1;
} else if(strpos($tmp, 'Yahoo! Slurp') !== false){
     $false = 1;
} else if(strpos($tmp, 'msnbot') !== false){
    $false = 1;
} else if(strpos($tmp, 'Sosospider') !== false){
    $false = 1;
} else if(strpos($tmp, 'YodaoBot') !== false || strpos($tmp, 'OutfoxBot') !== false){
     $false = 1;
} else if(strpos($tmp, 'Sogou web spider') !== false || strpos($tmp, 'Sogou Orion spider') !== false){
    $false = 1;
} else if(strpos($tmp, 'fast-webcrawler') !== false){
    $false = 1;
} else if(strpos($tmp, 'Gaisbot') !== false){
     $false = 1;
} else if(strpos($tmp, 'ia_archiver') !== false){
    $false = 1;
} else if(strpos($tmp, 'altavista') !== false){
    $false = 1;
} else if(strpos($tmp, 'lycos_spider') !== false){
     $false = 1;
} else if(strpos($tmp, '360Spider') !== false){
     $false = 1;
}
if($false==0) {
 header('HTTP/1.1 500 Internal Server Error'); exit;

exit('<html><head><title>404 Not Found</title></head><body bgcolor="white"><center><h1>404 Not Found</h1></center><hr><center>nginx</center></body></html>');

 }

转载请注明:谷谷点程序 » php仅让搜索引擎访问的方法