根据user-agent判断蜘蛛代码 黑帽跳转代码

黑帽seo手段中有一个大家都在用的技巧,在服务端判断 客户端浏览器的user-agent然后做进一步操作,

如果是搜索引擎的user-agent则301跳转 目前网上好多欺骗友情链接的就是这个做法(代码会放在最后)

具体还有很多思路,跳转了,乔页等 今天仅把代码放出来 php的代码

声明 代码都是百度下来的  先写个简单的
根据php的 $_SERVER['HTTP_USER_AGENT']来进行判断

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
$tmp = $_SERVER['HTTP_USER_AGENT'];
if(strpos($tmp, 'Googlebot') !== false){
    echo '谷歌';
} else if(strpos($tmp, 'Baiduspider') >0){
    echo '百度';
} else if(strpos($tmp, 'Yahoo! Slurp') !== false){
    echo '雅虎';
} else if(strpos($tmp, 'msnbot') !== false){
    echo 'Msn';
} else if(strpos($tmp, 'Sosospider') !== false){
    echo '搜搜';
} else if(strpos($tmp, 'YodaoBot') !== false || strpos($tmp, 'OutfoxBot') !== false){
    echo '有道';
} else if(strpos($tmp, 'Sogou web spider') !== false || strpos($tmp, 'Sogou Orion spider') !== false){
    echo '搜狗';
} else if(strpos($tmp, 'fast-webcrawler') !== false){
    echo 'Alltheweb';
} else if(strpos($tmp, 'Gaisbot') !== false){
    echo 'Gais';
} else if(strpos($tmp, 'ia_archiver') !== false){
    echo 'Alexa';
} else if(strpos($tmp, 'altavista') !== false){
    echo 'AltaVista';
} else if(strpos($tmp, 'lycos_spider') !== false){
    echo 'Lycos';
} else if(strpos($tmp, 'Inktomi slurp') !== false){
    echo 'Inktomi';
}
?>

第二段带跳转的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
$flag = false;
$tmp = $_SERVER['HTTP_USER_AGENT'];
if(strpos($tmp, 'Googlebot') !== false){
    $flag = true;
} else if(strpos($tmp, 'Baiduspider') >0){
    $flag = true;
} else if(strpos($tmp, 'Yahoo! Slurp') !== false){
    $flag = true;
} else if(strpos($tmp, 'msnbot') !== false){
    $flag = true;
} else if(strpos($tmp, 'Sosospider') !== false){
    $flag = true;
} else if(strpos($tmp, 'YodaoBot') !== false || strpos($tmp, 'OutfoxBot') !== false){
    $flag = true;
} else if(strpos($tmp, 'Sogou web spider') !== false || strpos($tmp, 'Sogou Orion spider') !== false){
    $flag = true;
} else if(strpos($tmp, 'fast-webcrawler') !== false){
    $flag = true;
} else if(strpos($tmp, 'Gaisbot') !== false){
    $flag = true;
} else if(strpos($tmp, 'ia_archiver') !== false){
    $flag = true;
} else if(strpos($tmp, 'altavista') !== false){
    $flag = true;
} else if(strpos($tmp, 'lycos_spider') !== false){
    $flag = true;
} else if(strpos($tmp, 'Inktomi slurp') !== false){
    $flag = true;
}
if($flag == false){
   header("Location: http://www.saoyu.com" . $_SERVER['REQUEST_URI']);
    // 自动转到http://www.saoyu.com 对应的网页
    // $_SERVER['REQUEST_URI'] 为域名后面的路径
    // 或 换成 header("Location: http://www.saoyu.com/abc/d.php");
   exit();
}
?>

第三段代码 是 判断后301跳转的

1
2
3
4
5
6
7
if (preg_match(#(google|slurp@inktomi|yahoo! slurp|msnbot)#si”, $_SERVER['HTTP_USER_AGENT'])) {
 
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: http://www.saoyu.com/”);
exit;
 
}}

最后声明 黑帽手段有风险 请慎用

无觅相关文章插件

本文固定链接: http://www.saoyu.com/php-2/715/ | 黑帽Seo_网络安全_网赚博客_网络营销_骚鱼博客

该日志由 骚鱼 于2011年12月31日发表在 PHP 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: 根据user-agent判断蜘蛛代码 黑帽跳转代码 | 黑帽Seo_网络安全_网赚博客_网络营销_骚鱼博客
关键字:
【上一篇】
【下一篇】

根据user-agent判断蜘蛛代码 黑帽跳转代码:等您坐沙发呢!

发表评论

快捷键:Ctrl+Enter