Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache .htaccess从浏览器捕获中仅避免一个文件_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache .htaccess从浏览器捕获中仅避免一个文件

Apache .htaccess从浏览器捕获中仅避免一个文件,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我的htaccess文件中有以下内容 ExpiresActive on ExpiresDefault A0 ExpiresByType image/gif A29030400 ExpiresByType image/jpeg A29030400 ExpiresByType image/png A29030400 ExpiresByType text/css A29030400 ExpiresByType text/javascript A29030400 ExpiresByType applic

我的htaccess文件中有以下内容

ExpiresActive on
ExpiresDefault A0
ExpiresByType image/gif A29030400
ExpiresByType image/jpeg A29030400
ExpiresByType image/png A29030400
ExpiresByType text/css A29030400
ExpiresByType text/javascript A29030400
ExpiresByType application/x-javascript A29030400
一切都很好。现在我有一个配置文件,它是config.js,我不希望浏览器捕捉到它

有人知道如何避免使用htaccess只捕获一个文件吗

我使用的是FileMatch..如果文件是lang.js/config.js,则将到期日设置为1天,否则如上所述。。低于正确设置或我需要执行的其他操作

 <IfModule mod_expires.c>
   ExpiresActive On

   ExpiresByType text/css "access plus 6 months"
   ExpiresByType text/x-javascript "access plus 6 months"
   ExpiresByType text/javascript "access plus 6 months"
   ExpiresByType application/javascript "access plus 6 months"
   ExpiresByType image/jpg "access plus 2 years"
   ExpiresByType image/jpeg "access plus 2 years"
   ExpiresByType image/gif "access plus 2 years"
   ExpiresByType image/png "access plus 2 years"
   ExpiresByType image/x-icon "access plus 2 years"
# Do not cache dynamically generated pages.
   ExpiresByType text/html A1
# Cache all files for a month after access (A).
   ExpiresDefault "access plus 21 days"

 # Dont catch below files

   <FilesMatch "^(lang|config)\.js$">
       ExpiresDefault "access plus 1 day"
   </FilesMatch>
 </IfModule>

过期于
ExpiresByType文本/css“访问加6个月”
ExpiresByType text/x-javascript“访问加6个月”
ExpiresByType文本/javascript“访问加6个月”
ExpiresByType应用程序/javascript“访问加6个月”
过期按类型映像/jpg“访问加2年”
过期按类型图像/jpeg“访问加2年”
ExpiresByType image/gif“访问加2年”
过期按类型图像/png“访问加2年”
过期按类型图像/x图标“访问加2年”
#不要缓存动态生成的页面。
ExpiresByType文本/html A1
#访问后缓存所有文件一个月(a)。
ExpiresDefault“访问加21天”
#不要捕捉下面的文件
ExpiresDefault“访问加1天”
先谢谢你。 当做 Mona使用该指令

<Files "config.js">
  #your desired config here
</Files>
<Directory "/dir/with/different/config">
  #your desired config here
</Directory>

何福布斯。。最后一个疑问。。我可以在IfModule mod_expires.c指令中使用吗。。在我的情况下,如果文件是config.js,那么不要捕获它。是的,你可以。实际上,您应该将所有内容放在同一个IfModule指令中。另外,如果有必要,你可以把
放在
里面。我已经再次编辑了我的答案,请告诉我你是否是优秀的FOIB。。非常感谢你的帮助。。我最近开始学这个。。
<FilesMatch "^(lang|config)\.js$">
   ExpiresByType application/javascript "access plus 1 day"
</FilesMatch>