|
根据蜘蛛判断跳转代码(PHP代码+js开源代码)-SEO排名收录
接下来E58技术就给大家分享两种,根据蜘蛛类型来判断跳转的开源代码。
js版
<script language="javascript">
var pattern = /baidu/gi;
var pattern1= /google/gi;
"window.location='https://www.heimaoxuexi.net'",10*1000);
</script>
判断搜索引擎进行不同的跳转
百度蜘蛛就会跳转到 https://www.heimaoxuexi.net/站群程序
判断是谷歌蜘蛛就会跳到 https://www.heimaoxuexi.net/
如果是搜索引擎的user-agent则301跳转
具体还有很多思路,跳转了,乔页等 今天仅把代码放出来 php的代码
声明 代码都是百度下来的 先写个简单的
根据php的 $_SERVER[‘HTTP_USER_AGENT’]来进行判断
<?php
$flag = false;
$tmp = $_SERVER['HTTP_USER_AGENT'];
if(strpos($tmp, 'Googlebot') !== false){
$flag = true;
if($flag == false){
header("Location: https://www.heimaoxuexi.net" . $_SERVER['REQUEST_URI']);
// 自动转到https://www.heimaoxuexi.net 对应的网页
// $_SERVER['REQUEST_URI'] 为域名后面的路径
// 或 换成 header("Location: https://www.heimaoxuexi.net/index.php?s=php");
exit();
}
?>
|
|