For all files, except pdf, in a specific directory as well as its sub-directories on the server, I would like to set the expiration header to 10 hours. How can I do this in the .htaccess file?
<Directory "/foldername">
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType * "access plus 10 hours"
</IfModule>
</Directory>
I understand Directory cannot be used in .htaccess. But how to do this?
You could put the .htaccess into the specific directory, and do it in there without any further restriction. Or use an
Ifcondition, to apply this based on what the request URI starts with.ExpiresByType *won't work, according to the documentation, this needs an actual mime type as "argument".But
ExpiresDefaultalso exists, and allows you to specify the default expiry for all files.