mod deflate not compressing subdirectories of root

I am about 48 hours into trying to solve a gzip deflate issue and realize I may need to ask for help, hehehe.

I have finally gotten the deflate module enabled on my shared Unix server via .htaccess after realizing I needed to turn on compression in my php.ini file.

Read More

PageSpeed is telling me that my root HTML is encoded with gzip for the site and I am getting 77.3% compression for the WordPress site theoleandersofsanleon.com but none of the files in any sub directories are being compressed (mainly css and js files in my wordpress directory and it’s sub directories).

I didn’t think it was necessary but I went ahead and tried to use the directive Directory and then the directive Location to no avail.

I put a phpinfo.php file in the root if you need to see that for any server specs.

Here is what I have in my .htaccess file for both my htdocs directory and wordpress directory:

<IfModule mod_deflate.c>
# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Please let me know if you need any more information, and thank you very much for any help, it will be greatly appreciated and I will be able to start letting my hair grow back 😎

Related posts

Leave a Reply

1 comment

  1. Try this in your top level .htaccess file. This the content generated when using the optimiser in cPanel.

    <IfModule mod_deflate.c>
        SetOutputFilter DEFLATE
      <IfModule mod_setenvif.c>
        # Netscape 4.x has some problems...
        BrowserMatch ^Mozilla/4 gzip-only-text/html
    
        # Netscape 4.06-4.08 have some more problems
        BrowserMatch ^Mozilla/4.0[678] no-gzip
    
        # MSIE masquerades as Netscape, but it is fine
        # BrowserMatch bMSIE !no-gzip !gzip-only-text/html
    
        # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
        # the above regex won't work. You can use the following
        # workaround to get the desired effect:
        BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
    
        # Don't compress images
        SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
      </IfModule>
    
      <IfModule mod_headers.c>
        # Make sure proxies don't deliver the wrong content
        Header append Vary User-Agent env=!dont-vary
      </IfModule>
    </IfModule>