判断搜索引擎来路进行跳转的代码

小小新手2090 2012-09-11 08:30:31
求大侠写个搜索引擎来路判断代码进行跳转
如果是百度来的 就跳到 http://aaaa.com
直接输入就不跳转
之前建过人写了代码但是不知道把代码放到那里
比如下面的

$RUrl = $_SERVER ['HTTP_REFERER'];
if (! empty ( $RUrl )) {
$UArray = parse_url ( $RUrl );
$UHost = $UArray ['host'];
switch ($UHost) {
case 'www.baidu.com' :
header ( "Location: http://aaa.com" );
break;
case 'www.google.com' :
header ( "Location: http://bbb.com" );
break;
case 'www.sogou.com' :
header ( "Location: http://ccc.com" );
break;
default :
echo $UHost;
break;
}
}
echo '直接輸入';
--------------------------------------------------------------------------------

和下面
章内容摘要:
PHP判断搜索引擎来路跳转代码: ?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') !==
PHP判断搜索引擎来路跳转代码:

<?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.hake.cc" . $_SERVER['REQUEST_URI']);
require_once("cd.htm");
// 自动转到http://www.hake.cc 对应的网页
// $_SERVER['REQUEST_URI'] 为域名后面的路径
// 或 换成 header("Location: http://www.hake.cc/abc/d.php");
exit();
}
else
{
require_once("news1.htm");
}
?>



--------------------------------------------------------------------------------

JS判断搜索引擎来路跳转代码:

var regexp=//.(sogou|soso|baidu|google|youdao|yahoo|bing|118114|biso|gougou|ifeng|ivc|sooule|niuhu|biso)(/.[a-z0-9/-]+){1,2}///ig;
var where =document.referrer;
if(regexp.test(where))
{
window.location.href='http:hake.cc'
}


--------------------------------------------------------------------------------
...全文
760 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
itscat 2013-10-04
  • 打赏
  • 举报
回复
使用php记录搜索引擎的来路以及用户搜索输入的关键字 http://3aj.cn/php/23.html
十一文 2012-09-13
  • 打赏
  • 举报
回复
<?php
//作者:http://www.tongqiong.com
function get_naps_bot()
{
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);

if (strpos($useragent, 'googlebot') !== false){
return 'Google';
}

if (strpos($useragent, 'baiduspider') !== false){
return 'Baidu';
}
if (strpos($useragent, 'msnbot') !== false){
return 'Bing';
}

if (strpos($useragent, 'slurp') !== false){
return 'Yahoo';
}

if (strpos($useragent, 'sosospider') !== false){
return 'Soso';
}

if (strpos($useragent, 'sogou spider') !== false){
return 'Sogou';
}

if (strpos($useragent, 'yodaobot') !== false){
return 'Yodao';
}
return false;
}

function nowtime(){
$date=date("Y-m-d.G:i:s");
return $date;
}

$searchbot = get_naps_bot();

if ($searchbot) {
$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);
$url=$_SERVER['HTTP_REFERER'];
$file="www.tongqiong.com.txt";
$time=nowtime();
$data=fopen($file,"a");
fwrite($data,"Time:$time robot:$searchbot URL:$tlc_thispage\n");
fclose($data);
}
//作者:http://www.tongqiong.com
?>

复制来的 楼主看看
xuzuning 2012-09-13
  • 打赏
  • 举报
回复
设函数 spider 返回搜索引擎的名字,则有
if(spider() == 'Baiduspider') header('Loction: http://aaaa.com');
小小新手2090 2012-09-13
  • 打赏
  • 举报
回复
我已放了 无效的[Quote=引用 1 楼 的回复:]
你上面的

$RUrl = $_SERVER ['HTTP_REFERER'];
if (! empty ( $RUrl )) {
$UArray = parse_url ( $RUrl );
$UHost = $UArray ['host'];
switch ($UHost) {
case 'www.baidu.com' :
header ( "Locati……
[/Quote]
黄袍披身 2012-09-12
  • 打赏
  • 举报
回复
你上面的

$RUrl = $_SERVER ['HTTP_REFERER'];
if (! empty ( $RUrl )) {
$UArray = parse_url ( $RUrl );
$UHost = $UArray ['host'];
switch ($UHost) {
case 'www.baidu.com' :
header ( "Location: http://aaa.com" );
break;
case 'www.google.com' :
header ( "Location: http://bbb.com" );
break;
case 'www.sogou.com' :
header ( "Location: http://ccc.com" );
break;
default :
echo $UHost;
break;
}
}
echo '直接輸入';

不可以用吗?但是不知道把代码放到哪里?放到你想产生效果的页面啊

21,882

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧