Apache .htaccess with mod_expires not working for certain directories

.htaccessapache-2.2

I have a Joomla site that I am trying to enable caching using mod_expires. I have the .htaccess in the root of the site and have added the options as found on the page http://www.pactsoftware.nl/tools/joomla-optimization.html

Using the PageSpeed extension in Chrome, prior to adding this in my .htaccess, my site scores a 55 (Caching is at the top, and lists a lot of images, CSS, and JS files). After these directives, it scores 70, with caching in the yellow, but still lists some image files (some are two directories deep and the rest are four).

I checked for any other .htaccess files in the Joomla root, but none are between those folders and the root. It is almost as if .htaccess only works in that one directory, not the subfolders.

I have tried putting a .htaccess in each affected subdirectory, but it does not work.

Does anyone have any ideas?

Best Answer

Need checking Apache config file about 2 points:

  1. mod_expires is enable or not? Uncomment the line like this:

    LoadModule expires_module modules/mod_expires.so

  2. DocumentRoot is allow overriding config where .htaccess placed or not? Like this:

    <Directory "/path/to/your/docroot">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>