除非来自指定文件,否则如何阻止对文件或目录的请求?

In my .htaccess file I have the following RewriteRules:

RewriteRule ^content/(.*)\.(txt|md|mdown)$ error [R=301,L]
RewriteRule ^site/(.*) error [R=301,L]

These work well for blocking direct access to txt|md|mdown file types and the entire site/ directory.

That said, I'm working on building out an .appcache file to cache my site for offline viewing and need to be able to access these files and directories from the .appcache file. I have the .appcache file set up and I'm getting the following error in the browser:

Application Cache Error event: Resource fetch failed (-1) http://website.com/site/panel/blueprints/home.php

Is it possible to update the RewriteRule to allow for access from this file?

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite.com.br/.*$ [NC]
RewriteRule .*\.(pdf|cdr|indd|psd|jpg|jpeg|ai|zip|rar|7z)$ - [F]

just replace yoursite.com for your site and .*$ for the specific file that you need.

<Files "file_name.appcache"> 
  // rewrite yours in it
</Files>

hope it helps :)