支付宝赞助帐号:service@kuitao8.com 

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

Created2017-06-28   Views 390    Author 懒人程序
 $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自动生成api接口档
下一篇: php去除html标签函数
支持键盘 ← →

邮件订阅

订阅我们的精彩内容