PHP和JS判定来路跳转到指定页面
发布时间:2023-10-30 10:31:41 所属栏目:PHP教程 来源:未知
导读: PHP根据referer跳转:
代码如下
1
$ref = $_SERVER['HTTP_REFERER'];
if(stripos($ref,"baidu") || stripos($ref,"google"
代码如下
1
$ref = $_SERVER['HTTP_REFERER'];
if(stripos($ref,"baidu") || stripos($ref,"google"
PHP根据referer跳转: 代码如下 1 $ref = $_SERVER['HTTP_REFERER']; if(stripos($ref,"baidu") || stripos($ref,"google") { header("Location: http://www.111com.net"); exit; } ?> 根据UA跳转: 代码如下 1 $userAgent = $_SERVER['HTTP_USER_AGENT']; if(stripos($userAgent,"Moz") || stripos($userAgent,"baidu")) { header("Location: http://www.111com.net"); } ?> header()函数的定义如下: void header (string string [,bool replace [,int http_response_code]]) 可选参数replace指明是替换前一条类似标头还是添加一条相同类型的标头,默认为替换。 第二个可选参数http_response_code强制将HTTP相应代码设为指定值。 header函数中Location类型的标头是一种特殊的header调用,常用来实现页面跳转。注意:1.location和“:”号间不能有空格,否则不会跳转。 (编辑:92站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐