Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

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

share|improve this question
up vote 1 down vote accepted

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

See 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).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.