Rumah > Artikel > pembangunan bahagian belakang > 判断搜索引擎来路进行跳转的代码
求大侠写个搜索引擎来路判断代码进行跳转
如果是百度来的 就跳到 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判断搜索引擎来路跳转代码:
$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'
}
--------------------------------------------------------------------------------
你上面的
$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 '直接?入';
不可以用吗?但是不知道把代码放到哪里?放到你想产生效果的页面啊
我已放了 无效的 你上面的
$RUrl = $_SERVER ['HTTP_REFERER'];
if (! empty ( $RUrl )) {
$UArray = parse_url ( $RUrl );
$UHost = $UArray ['host'];
switch ($UHost) {
case 'www.baidu.com' :
header ( "Locati……
设函数 spider 返回搜索引擎的名字,则有
if(spider() == 'Baiduspider') header('Loction: http://aaaa.com');
<?php //作者:http://www.tongqiong.comfunction 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?>
使用php记录搜索引擎的来路以及用户搜索输入的关键字
http://3aj.cn/php/23.html