3
我需要知道如何拒絕訪問圖像文件的文件夾,但只允許它從PHP/HTML閱讀它。拒絕直接訪問文件,但允許PHP和HTML從它讀取.htaccess
我認爲最好的辦法是在該文件夾的東西使用的.htaccess像
deny from all
Options -indexes
AddHandler cgi-script .php .htm .html .sh
Options -ExecCGI
但這並不工作,因爲我必須在根文件夾的.htaccess以下
<FilesMatch "\.(gif|jpe?g|doc?x|pdf|zip|png)$">
AddHandler cgi-script .php .htm .html .sh
Allow from all
</FilesMatch>
<Files 403.shtml>
order allow,deny
allow from all
</Files>
解決方案
RewriteCond %{HTTP_HOST} ^xxx.com$
RewriteRule ^/?$ "http\:\/\/www\.xxx\.com\/index\.php" [R=301,L]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?xxx\.com/.*$ [NC]
RewriteRule _files/photo/([^/]+)\.(gif|png|jpg)$ - [F]
did not work either ...?任何專家?