0

基本上,Apache 目录中的所有文件都无法访问,除了图像。图像应该是可访问的,但前提是通过网站加载。如果我根据referer设置Apache规则很容易绕过: http: //www.mustap.com/phpzone_post_62_how-to-bypass-the-referer-se 当然这不是正确的选择。

我的 Apache 配置文件:

<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>

如何在不将图像放入数据库的情况下解决此问题?

谢谢

4

1 回答 1

2

确定的一种方法是通过 PHP 脚本运行所有图像,该脚本使用类似readfile()检查请求的图像然后输出它的东西。

例如:site.com/image.php?name=logo.jpg

该脚本可以检查用户是否在您的站点上进行了会话,如果没有,则表示他们在没有先查看站点的情况下请求图像(除非禁用 cookie)。

不过,这会增加加载时间,因此您必须考虑实施的成本/收益。

于 2012-03-06T09:08:27.787 回答