海运的博客

PHP和JS判断来路跳转到指定页面

发布时间:June 4, 2013 // 分类:PHP // No Comments

PHP根据referer跳转:

<?php
$ref = $_SERVER['HTTP_REFERER'];
        if(stripos($ref,"baidu") || stripos($ref,"google")
    {
        header("Location: https://www.haiyun.me"); 
        exit;
    }
?>

JS判断方法:

<script>
    var s=document.referrer;
    if(s.indexOf("baidu")>0||s.indexOf("soso")>0||s.indexOf("google")>0||s.indexOf("yahoo")>0||s.indexOf("sogou")>0||s.indexOf("youdao")>0||s.indexOf("bing")>0)
    {
    self.location="https://www.haiyun.me";
    }
</script>

根据UA跳转:

<?php
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if(stripos($userAgent,"Moz") || stripos($userAgent,"baidu"))
    {
        header("Location: https://www.haiyun.me");
    }
?>
分类
最新文章
最近回复
  • nono: 修改光猫型号是做啥子用的
  • 960: root账号默认密码hg2x0 不对哇
  • rer: 感谢分享!~
  • opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
  • zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...