Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.js -f
RewriteRule ^(.+) $1.gz [L]
I have a directory with a "main.js", and a "main.gz". I was hoping the Apache server would send out the main.gz, and that the browser would decompress and treat it as, main.js. But the server sends back - main.js. Is there some error in the above?
RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/$1.gz -f
RewriteRule ^(([^/]+/)*[^.]+)\.js$ /$1.gz [L]
Also make sure that the MIME-type is declared properly for .gz files, using something like:
AddType application/x-gzip .gz
Jim