下面的代码,是判断蜘蛛ua,除了蜘蛛全部跳转到某个页面(我自己弄了个静态的index.html)
//判断蜘蛛函数
function find_spider(){
$useragent = strtolower(empty($useragent) ? $_SERVER['HTTP_USER_AGENT'] : '');
$spider_arr=array(
'bot',
'spider',
'slurp',
'ia_archiver',
);
foreach($spider_arr as $spider){
$spider = strtolower($spider);
if(strstr($useragent,$spider)){
return true;
}
}
return false;
}
if (!find_spider()){
header('Location: /index.html');
exit();
}
把这个代码加到首页就可以。
方法转自4414 @没有流量的站长
https://www.4414.cn/thread-122631-1-1.html
本文来自投稿,不代表忆夜立场,如若转载,请注明出处:https://98seo.com/seo/970.html