[英]How can I block requests for a file or directory unless it comes from a specified file?
在我的.htaccess文件中,我具有以下RewriteRules:
RewriteRule ^content/(.*)\.(txt|md|mdown)$ error [R=301,L]
RewriteRule ^site/(.*) error [R=301,L]
它們非常適合阻止直接訪問txt|md|mdown
文件類型和整個site/
目錄。
也就是說,我正在構建一個.appcache
文件以緩存我的站點以供脫機查看,並且需要能夠從.appcache
文件訪問這些文件和目錄。 我已設置.appcache
文件,並且在瀏覽器中遇到以下錯誤:
Application Cache Error event: Resource fetch failed (-1) http://website.com/site/panel/blueprints/home.php
是否可以更新RewriteRule以允許從該文件進行訪問?
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite.com.br/.*$ [NC]
RewriteRule .*\.(pdf|cdr|indd|psd|jpg|jpeg|ai|zip|rar|7z)$ - [F]
只需將yoursite.com替換為您的站點,並將。* $替換為所需的特定文件即可。
<Files "file_name.appcache">
// rewrite yours in it
</Files>
希望能幫助到你 :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.