Wednesday, 7 October 2020

GZIP only compresses files when full file path specified - won't compress root

If I include the following in my .htaccess, GZIP will only compress files when the full path to the file is specified:

RewriteRule ^ index.php [L]

But the above rewrite is necessary to allow my CMS to function.

So for example:

https://karenkingston.co.uk isn't compressed, but https://karenkingston.co.uk/index.php is, and indeed https://karenkingston.co.uk/themes/coach/js/jquery.scripts.js also compresses.

PHP 7.2 but changing versions doesn't help. Nor does it help to enable GZIP from .htaccess vs. CPanel.

Here's the full .htaccess

Options -indexes

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=302,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

AddType application/vnd.ms-fontobject .eot 
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType application/x-font-woff2 .woff2
AddType image/svg+xml .svg

ExpiresActive on
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType application/x-font-woff2 "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/html "access plus 1 month"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/x-javascript "access plus 1 year"
ExpiresByType application/pdf "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 1 month"

ErrorDocument 404 /

Redirect 301 /home https://karenkingston.co.uk
Redirect 301 /search https://karenkingston.co.uk

Any ideas?



from GZIP only compresses files when full file path specified - won't compress root

No comments:

Post a Comment