Home Backend Development PHP Tutorial PHP利用REFERER根居访问来地址进行页面跳转_PHP

PHP利用REFERER根居访问来地址进行页面跳转_PHP

Jun 01, 2016 am 11:59 AM
referer Page jump

比如,我有一个开发一个黄页源码上转到了。之前定了一个演示程序地址: 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;
}

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of PHP page jump function: page jump skills of header, location, redirect and other functions Detailed explanation of PHP page jump function: page jump skills of header, location, redirect and other functions Nov 18, 2023 pm 05:08 PM

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 Use uniapp to achieve page jump animation effect Nov 21, 2023 pm 02:15 PM

Use uniapp to achieve page jump animation effect

How to set up Referer in Nginx to prevent image theft How to set up Referer in Nginx to prevent image theft May 12, 2023 pm 06:52 PM

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 PHP code example: How to use POST to pass parameters and implement page jumps Mar 07, 2024 pm 01:45 PM

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 UniApp error: Unable to find a solution for 'xxx' page jump Nov 25, 2023 am 09:53 AM

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

PHP+Referer realizes image hotlink prevention! (Attached with example code) PHP+Referer realizes image hotlink prevention! (Attached with example code) Nov 21, 2022 pm 05:25 PM

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

How to implement page jump and navigation in uniapp How to implement page jump and navigation in uniapp Oct 20, 2023 pm 02:07 PM

How to implement page jump and navigation in uniapp

How to use routing to implement page jump in Vue? How to use routing to implement page jump in Vue? Jul 21, 2023 am 08:33 AM

How to use routing to implement page jump in Vue?

See all articles