apache.htaccessexpires-header

Negative Specific FilesMatch in Apache2


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>

Solution

  • Try:

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