Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

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

share|improve this answer
add comment

Your Answer

 
discard

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