Php Apache目录和映像的安全性
基本上,除了图像之外,Apache目录中的所有文件都是不可访问的。图像应该是可访问的,但只有通过网站加载。 如果我基于referer设置Apache规则,则很容易忽略: 当然,这不是正确的选择 我的Apache配置文件:Php Apache目录和映像的安全性,php,apache,referer,Php,Apache,Referer,基本上,除了图像之外,Apache目录中的所有文件都是不可访问的。图像应该是可访问的,但只有通过网站加载。 如果我基于referer设置Apache规则,则很容易忽略: 当然,这不是正确的选择 我的Apache配置文件: <Directory /var/www/path> Order allow,deny Deny from all Options -Indexes # Check against the referer, first level ch
<Directory /var/www/path>
Order allow,deny
Deny from all
Options -Indexes
# Check against the referer, first level check
SetEnvIf Referer domain1\.com domain1
SetEnvIf Referer domain1\.com domain2
<FilesMatch \.(jpg|jpeg|gif|png)$>
Order deny,allow
Deny from all
Allow from env=domain1
Allow from env=domain2
</FilesMatch>
</Directory>
命令允许,拒绝
全盘否定
选项-索引
#对照推荐人进行检查,一级检查
SetEnvIf Referer domain1\.com domain1
SetEnvIf Referer domain1\.com domain2
命令拒绝,允许
全盘否定
允许来自env=domain1
允许来自env=domain2
我如何在不将图像放入数据库的情况下解决此问题
谢谢一种确定的方法是通过PHP脚本运行所有图像,该脚本使用类似于
readfile()
的内容来检查请求的图像,然后将其输出
例如:site.com/image.php?name=logo.jpg
脚本可以检查用户是否在您的站点上有会话,如果他们没有,则表示他们在未首先查看站点的情况下请求图像(除非禁用cookie)
<>这将增加加载时间,所以你必须考虑实现的成本/效益。小心:Stuti.com /Myphiph.Name=…/…/ETC/PASWD;谢谢我还发现了这个链接,它非常有用: