This is how i fixed once the same problem.
Add new types in .htaccess:
AddEncoding gzip .jsgz .cssgz .htmlgz .datagz
AddType application/javascript .jsgz
AddType text/css .cssgz
AddType text/html .htmlgz
AddType text/plain .datagz
This was done this way because AddType
instruction didn't accept extensions in the form .html.gz.
Then modify your rewrite rule:
RewriteRule ^(.+)\.(html|css|js|data)$ $1.$2gz [L]
And finally rename your files. Remove dots from .html.gz, .js.gz and so on.
The full .htaccess would look like this:
AddEncoding gzip .jsgz .cssgz .htmlgz .datagz
AddType application/x-javascript .jsgz
AddType text/css .cssgz
AddType text/html .htmlgz
AddType text/plain .datagz
RewriteEngine on
# If client accepts compressed files
RewriteCond %{HTTP:Accept-Encoding} gzip
# and if compressed file exists
RewriteCond %{REQUEST_FILENAME}gz -f
# send .html.gz instead of .html
RewriteRule ^(.+)\.(html|css|js|data)$ $1.$2gz [L]