如何在拒绝所有文件夹中访问img

时间:2017-03-22 11:15:06

标签: php .htaccess

我有一个文件夹'屏幕'充满图像,在这个文件夹中我有一个.htaccess:

Order Deny,Allow
Deny From All
Allow from 1xx.xx.xx.xxx

(这是服务器的IP)

所以在我的服务器上,我可以访问该文件夹的信息,我可以包含img's但我不能显示img,所以

<img src="screens/img.png"/>

收到“禁止访问”错误。

我只在文件“test.php”中显示屏幕,你必须在会话中访问test.php。

所以我试过

Order Deny,Allow
Deny From All
Allow from 1xx.xx.xx.xxx
<Files test.php>
    Order Allow,Deny
    Allow from all
</Files>

但它仍然无效。任何消化?

1 个答案:

答案 0 :(得分:3)

使用

编写php代理
file_get_contents("IMG PATH HERE");

然后使用正确的标题返回它。 PNG / JPG或其他任何东西..

HTML代码将指向php文件,例如带有id或path:

<img src="image.php?id=IMGID" />