Today, the editor will introduce to you a more comprehensive PHP and JS method to determine the source and jump to the specified page. I hope this method will be helpful to all students.
PHP jumps according to referer:
The code is as follows
|
Copy code
|
||||||||||
If(stripos($ref,"baidu") || stripos($ref,"google") { header("Location: http://www.bKjia.c0m"); exit;} ?>
|
The code is as follows | Copy code |
$userAgent = $_SERVER['HTTP_USER_AGENT']; if(stripos($userAgent,"Moz") || stripos($userAgent,"baidu")) { header("Location: http://www.bKjia.c0m"); } ?> The header() function is defined as follows: void header (string string [,bool replace [,int http_response_code]])
The optional parameter replace specifies whether to replace the previous similar header or add a header of the same type. The default is replacement.The code is as follows | Copy code |
<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="http://www.bKjia.c0m"; } </script> http://www.bkjia.com/PHPjc/632656.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632656.htmlTechArticleToday, the editor will introduce to you a more comprehensive PHP and JS method to determine the origin and jump to the specified page. I hope this method will be helpful to all students. PHP jumps according to referer: Code... |