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
FilesMatch should only match filenames. You can place the .htaccess
file inside the skins
directory and it should look something like this:
<FilesMatch "\.(jpg|png|gif)">
ExpiresDefault A2592000
</FilesMatch>
Alternatively, in httpd.conf
, you could use:
<Directory path_to_the_skins_dir>
<FilesMatch "\.(jpg|png|gif)">
ExpiresDefault A2592000
</FilesMatch>
</Directory>
Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With