1

I have a .htaccess in my document root, with the following:

    ExpiresActive On
    ExpiresDefault A0
    <FilesMatch "\\.(gif|jpe?g|png)$">
        ExpiresDefault A86400
    </FilesMatch>

However, for a particular sub directory, /images/avatar, I only want the the age to be 300 seconds. Thus, I created another .htaccess under /images/avatar with the following:

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault A300
</IfModule>

With the above settings, I fail to enforce expiry time of 300 seconds for the files under /images/avatar. However if I remove the .htaccess in root, the 300 seconds rule will be implied.

Any help? Thanks

1 Answers1

1

I suspect that the problem lies with the FilesMatch options being applied after the Directory options. Try specifying a FilesMatch directive in your avatar directory, something like:

<FilesMatch ".">
    ExpiresActive On
    ExpiresDefault A300
</FilesMatch>

See http://httpd.apache.org/docs/2.0/sections.html which explains that Directory options are applied first, and FilesMatch options are applied afterwards. In your case you had Directory options setting ExpiresDefault to A300, and then the parent FilesMatch option was applied on any match files in the sub directory (remember that setting options for a directory affects all sub directories).

PP.
  • 3,316
  • 6
  • 27
  • 31