时间:2021-07-01 10:21:17 帮助过:25人阅读
写个函数吧 简单的可以、起到防盗链作用
function checkurl(){
//如果直接从浏览器连接到页面,就连接到登陆窗口
//echo "referer:".$_SESSION['HTTP_REFERER'];
if(!isset($_SESSION['HTTP_REFERER'])) {
header("location: login");
exit;
}
$urlar = parse_url($_SESSION['HTTP_REFERER']);
//如果页面的域名不是服务器域名,就连接到登陆窗口
if($_SERVER['HTTP_HOST'] != $urlar["host"] && $urlar["host"] != "202.102.110.204" && $urlar["host"] != "http://blog.163.com/fantasy_lxh/") {
header("location: login.php");
exit;
}
}
checkurl()
?>