htaccess filesMatch exclusion

Posted by Hikari on Server Fault See other posts from Server Fault or by Hikari
Published on 2013-10-23T13:38:49Z Indexed on 2013/11/01 21:57 UTC
Read the original article Hit count: 180

Filed under:
|
|
|

I have the following directive in my htaccess

<filesMatch "\.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml|html?)$">
    FileETag None
    <ifModule mod_headers.c>
        Header unset ETag
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
    </ifModule>
</filesMatch>

I copied that regex from someplace in Web months ago. It should add those headers to any HTTP Response that does NOT have those extensions.

But it's not working, it's adding them to any Response.

I also need to create another directive to add Header set Cache-Control "max-age=3600, public" to Responses of files that DOES have them.

Could anybody help me make proper fileMatch regexes?

© Server Fault or respective owner

Related posts about apache2

Related posts about .htaccess