如何阻止来自其他各种网站的PHP文档的可访问性
我读了一些关于温暖连接图像的地方。 保护照片温暖的连接辅助设备,以阻止您的网站传输容量入室盗窃。 肯定会对PHP文档有益吗?
在我的实例中,我正在利用PHP文档从照片创建缩略图。 我不希望其他人从他们的网站上引用这些PHP文档。
0
Amit Kumar Gupta 2019-05-13 02:11:41
资源
分享
答案: 1
一种程序化方法是检查引荐来源,以查看来自您网站的需求:
<?php
$yoursite = "yoursite.com"; //Your site url without http://
$yoursite2 = "www.yoursite.com"; //Type your domain with www. this time
$referer = $_SERVER['HTTP_REFERER'];
//Check if browser sends referrer url or not
if ($referer == "") { //If not, set referrer as your domain
$domain = $yoursite;
} else {
$domain = parse_url($referer); //If yes, parse referrer
}
if($domain['host'] == $yoursite || $domain['host'] == $yoursite2) {
//Run your image generation code
} else {
//The referrer is not your site, we redirect to your home page
header("Location: http://yoursite.com");
exit(); //Stop running the script
}
?>
编辑
本文提供了一种使用PHP会话的替代方法。
0
BenV 2019-05-17 10:35:26
资源
分享
相关问题
0