判断搜索引擎来路进行跳转的代码
求大侠写个搜索引擎来路判断代码进行跳转
如果是百度来的 就跳到 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'
}
--------------------------------------------