PHP implementation of the Internet link to prohibit the way to view the Web page

Source: Internet
Author: User
Prohibit Internet links (such as search engines) from viewing Web page content
if (!empty ($_server[' http_referer '))
{
Preg_match ("/^" (http://)? [^/]+)/I ", $_server[' Http_referer '], $matches);
$host = $matches [2];
if ($host = = "211.152.50.35") | | ($host ==www.phpv.net))
{
}
Else
{
Header ("Location:http://www.phpv.net");
Exit
}
}
No direct input to the Web site to view the content
Else
{
Header ("Location:http://www.phpv.net");
Exit
}

Only click on the hyperlink (that is, <a href=...>) open page only http_referer environment variables, such as window.open (), window.location= ..., Window.showmodelessdialog () and other open windows do not have http_referer environment variables, such restrictions will make the site a lot less activity. Of course, the fish and bear cake can not be both, hehe.
Is it simpler to write?
if (($host!= "211.152.50.35") && ($host!=www.phpv.net)) {
Header ("Location:http://www.phpv.net");
Exit
}


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.