一号优惠经验分享网
51福利网的各种薅羊毛福利经验笔记

按UA,给搜索蜘蛛和用户不同的页面,真实的用户则跳转到注册登录

介绍一下这种seo方法
判断来路是搜索蜘蛛就让蜘蛛看到全部的页面代码
如果判断来路是真实的用户则跳转到注册页或者其他页面
既能达到想要的效果,又能做良好的seo优化,岂不是两全其美嘛

当然ua可用伪造的,所以还是要用服务器屏蔽一些垃圾爬虫的。下面只是辅助

51福利网

感觉那些垃圾广告网站就是用的这个去抄别人的关键词的

<?php
$http = false;
$http1 = $_SERVER['HTTP_USER_AGENT'];
if(strpos($http1, 'Googlebot') !== false){
$http = true;
} else if(strpos($http1, 'Baiduspider') >0){
$http = true;
} else if(strpos($http1, 'Yahoo! Slurp') !== false){
$http = true;
} else if(strpos($http1, 'msnbot') !== false){
$http = true;
} else if(strpos($http1, 'Sosospider') !== false){
$http = true;
} else if(strpos($http1, 'YodaoBot') !== false || strpos($http1, 'OutfoxBot') !== false){
$http = true;
} else if(strpos($http1, 'Sogou web spider') !== false || strpos($http1, 'Sogou Orion spider') !== false){
$http = true;
} else if(strpos($http1, 'fast-webcrawler') !== false){
$http = true;
} else if(strpos($http1, 'Gaisbot') !== false){
$http = true;
} else if(strpos($http1, 'ia_archiver') !== false){ 
$http = true;
} else if(strpos($http1, 'altavista') !== false){
$http = true;
} else if(strpos($http1, 'lycos_spider') !== false){
$http = true;
} else if(strpos($http1, 'Inktomi slurp') !== false){
$http = true;
} else if(strpos($http1, 'googlebot-mobile') !== false){
$http = true;
} else if(strpos($http1, '360Spider ') !== false){
$http = true;
} else if(strpos($http1, 'haosouspider') !== false){
$http = true;
} else if(strpos($http1, 'Sogou News Spider') !== false){
$http = true;
} else if(strpos($http1, 'YoudaoBot') !== false){
$http = true;
} else if(strpos($http1, 'bingbot') !== false){
$http = true;
} else if(strpos($http1, 'YisouSpider') !== false){
$http = true;
} else if(strpos($http1, 'ia_archiver') !== false){
$http = true;
} else if(strpos($http1, 'EasouSpider') !== false){
$http = true;
} else if(strpos($http1, 'JikeSpider') !== false){
$http = true;
} else if(strpos($http1, 'Sogou blog') !== false){
$http = true;
}
if($http == false){
header("Location: https://www.51yhyh.com/");
exit();
}
?>

以上代码包含了各大主流搜索引擎的蜘蛛,把其中1号优惠 · 51福利网的网址https://www.51yhyh.com替换为你要跳转的地址即可,这段代码可以放在index.php文件中,或者网站的头部文件中即可。

也可也如下更简单。自己修改为自己喜欢的

<?php  
  
$spiderAgents = array(  
    'Googlebot',  
    'Bingbot',  
    'Yahoo! Slurp',  
    // 其他搜索引擎蜘蛛简称...  
);  
  
// 获取用户代理字符串  
$yonghuAgent = $_SERVER['HTTP_USER_AGENT'];  
  
// 循环遍历已知的搜索引擎蜘蛛简称数组  
foreach ($yonghuAgent as $userAgentShort) {  
    // 使用正则表达式进行匹配  
    if (preg_match('/(?:^|.*\b)' . preg_quote($userAgentShort, '/') . '(?:$|.*\b)/i', $userAgent)) {  
       // echo "匹配到已知的搜索引擎蜘蛛:{$userAgentShort}\n";  
        // 如果成功匹配到已知的搜索引擎蜘蛛,则退出循环  
        break;  
    }  
}  
  
if (!isset($userAgentShort)) {  
    echo "未匹配到已知的搜索引擎蜘蛛\n";  
}  
?>

变一下 不匹配就调用登录函数

$userAgents = array(    
    'Googlebot',    
    'Bingbot',    
    'Yahoo! Slurp',    
    // 其他搜索引擎蜘蛛简称...    
);    
    
// 获取用户代理字符串    
$userAgent = $_SERVER['HTTP_USER_AGENT'];    
    
// 循环遍历已知的搜索引擎蜘蛛简称数组    
foreach ($userAgents as $userAgentShort) {    
    // 使用正则表达式进行匹配    
    if (preg_match('/(?:^|.*\b)' . preg_quote($userAgentShort, '/') . '(?:$|.*\b)/i', $userAgent)) {    
        // 这里应该定义或包含liveme_if_login()函数的代码  
        // liveme_if_login();    
    }    
}    

一号优惠 · 51福利网薅羊毛福利具有时效性,如已失效,请留言
文章名称:《按UA,给搜索蜘蛛和用户不同的页面,真实的用户则跳转到注册登录》-一号优惠 · 51福利网
免责申明:本站所有活动信息均来自网络,如有失效、违规、不实或侵权,请联系我们删除。谢谢

评论 抢沙发

一号优惠经验分享网最新最全薅羊毛,现金红包线报网

一号优惠经验分享网提供每日最新内部优惠,薅羊毛活动,现金红包领取,免费福利和网赚福利手机赚钱线报,打造中国最受欢迎的网赚信息发布平台!51福利网

51联盟线报群赚钱·合作·帮助

登录

找回密码

注册