PHP利用REFERER根居访问来地址进行页面跳转_PHP
Jun 01, 2016 am 11:59 AM比如,我有一个开发一个黄页源码上转到了。之前定了一个演示程序地址: http://www.bitsCN.com 而现在这个域名需要用来作其它的站,又不杀望原来的演示地址失效怎么办呢。那我就可以利用PHP REFERER来判断来源如果它是自至站长下载站的地址 我就把它己转移站点域名上。
我就是在http://www.bitsCN.com这个站点上的index.php里放置了如下的代码让其来源于 files.bitsCN.com 的访问定位到我的服务器常用软件下载 http://s.bitsCN.com
大家可以到这个页面里的 演示地址
复制代码 代码如下:
$referHost = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
$validDomain = 'files.bitsCN.com';
$valid = strstr($referHost, $validDomain) == $validDomain;
if(!empty($valid)){
echo '<script>location.href="http://s.bitsCN.com";</script>';
exit;
}

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of PHP page jump function: page jump skills of header, location, redirect and other functions

Use uniapp to achieve page jump animation effect

How to set up Referer in Nginx to prevent image theft

PHP code example: How to use POST to pass parameters and implement page jumps

UniApp error: Unable to find a solution for 'xxx' page jump

PHP+Referer realizes image hotlink prevention! (Attached with example code)

How to implement page jump and navigation in uniapp

How to use routing to implement page jump in Vue?
