views:

2919

answers:

1

Hi,
I'm trying to cache some files using a .htaccess file for Apache2. I want to cache a particular folder longer than anything else, so i've been trying to use the FilesMatch directive like this:

<FilesMatch "skins(.*)\.(jpg|png|gif)">
ExpiresDefault A2592000
</FilesMatch>

I'm hoping to be able to cache all image files in the /skins/ directory and it's subdirectories. However, I can't quite get the regular expression to work - Apache just ignores it altogether.

How do you match a folder with <FilesMatch> in a .htaccess file?

Cheers,
Matt

+3  A: 

FilesMatch should only match filenames so You could place the .htaccess file inside the "skins" directory and it should look something like,

<FilesMatch "\.(jpg|png|gif)">
ExpiresDefault A2592000
</FilesMatch>

or if in the httpd.conf file you could use,

<Directory path_to_the_skins_dir>
    <FilesMatch "\.(jpg|png|gif)">
    ExpiresDefault A2592000
    </FilesMatch>
</Directory>

good luck

hayato
Thanks very much for your help. I'll go for the multiple .htaccess files to save changing the main httpd.conf.Thanks again, Matt
fistameeny