当前位置:编程学习 > php >>

PHP实现禁止网外链接网址的方式查看网页

答案:// 禁止网外链接(例如搜索引擎)查看网页内容

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;
}
}
// 禁止直接输入网址查看网页内容
else
{
header("Location:http://www.phpv.net");
exit;
}




只有点击超链接(即<A href=>
这样写是不是更简洁些?
if(($host!="211.152.50.35")&&($host!=www.phpv.net)){
header("Location:http://www.phpv.net");
exit;
}

上一个:PHP怎样连接Oracle
下一个:一 php与XML、XSLT、Mysql的结合运用,安装篇

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,