views:

15

answers:

1

I want to give different expiry headers to different images on my site. they are contained in different folders right now, what I want to do is give then different expires headers with one main .htaccess file. I know this can be done with multiple .htaccess files in those folders but I dont want it to be implemented that way, It will clearly be tough to manage.

A: 

Try using FilesMatch directive in your .htaccess file.

Eg:

# cache most product images at client side
ExpiresActive on
<FilesMatch "^images/products/[^\.]*\.(gif|jpe?g|png)$">
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    Header append Cache-Control "public"
</FilesMatch>

EDIT: This seems to be wrong! FilesMatch is said to match only files, so you cannot match directories as well. Sorry for bad post.

xaralis
yea that was the issue, i have come up with a solution btw will post it when i get time :)
Umair