PHP实现禁止网外链接网址的方式查看网页
// 禁止网外链接(例如搜索引擎)查看网页内容 if(!empty( Copyright © 2008 chengduxinxi.com All Rights Reserved PHP编程开发 由朝夕网络维护
{ preg_match("/^(http:\/\/)?([^\/]+)/i", Copyright © 2008 chengduxinxi.com All Rights Reserved PHP编程开发 由朝夕网络维护
$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=...>) 打开的页面才有HTTP_REFERER环境变量, 其它如 window.open()、 window.location=...、window.showModelessDialog()等打开的窗口都没有HTTP_REFERER 环境变量; 这样的限制会使网站少很多活性。当然啦,鱼与熊掌不可兼得,呵呵。 这样写是不是更简洁些? if(($host!="211.152.50.35")&&($host!=www.phpv.net)){ header("Location:http://www.phpv.net"); exit; } |
