Negative Specific FilesMatch in Apache2

瘦欲@ 提交于 2019-12-11 06:28:22

问题


I want to set expiry date for all file except the 2-3 files how to use negative filematch in apache2

<FilesMatch "^(jquery-2.1.1.min.js|home_bg.png|jquery.ui.widget.js|jquery.placeholder.js|jquery.jscrollpane.js|jquery-ui-1.10.4.custom.min.js)$">
  ExpiresActive on 
  ExpiresDefault "access plus 1 month"
</FilesMatch>

Right now I make this happen by adding all other to file match list.

Is there anyway to use something like FilesNotMatch

<FilesNotMatch "^(style.css|responsive.css)$">
  ExpiresActive on 
  ExpiresDefault "access plus 1 month"
</FilesNotMatch>

or something like

<FilesMatch "!^(style.css|responsive.css)$">
  ExpiresActive on 
  ExpiresDefault "access plus 1 month"
</FilesMatch>

回答1:


Try:

<FilesMatch "(?<!style\.css|responsive\.css)$">
  ExpiresActive on 
  ExpiresDefault "access plus 1 month"
</FilesMatch>



回答2:


Try this:

<FilesMatch "^(?!(?:style|responsive)\.css).*$">
  ExpiresActive on 
  ExpiresDefault "access plus 1 month"
</FilesMatch>


来源:https://stackoverflow.com/questions/24879759/negative-specific-filesmatch-in-apache2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!