Gzip compressed website not working with IE
In my site I have some gzipped copies of the most used and largest files (because my hosting doesn't allow using the gzip compression module).
I have inserted rewrite rules in the htaccess file to send the gzipped copies when available, like this:
<FilesMatch "\.html\.gz$">
ForceType text/html
Header set Content-Encoding: gzip
</FilesMatch>
<FilesMatch "\.js\.gz$">
ForceTyp开发者_JAVA百科e text/javascript
Header set Content-Encoding: gzip
</FilesMatch>
<FilesMatch "\.css\.gz$">
ForceType text/css
Header set Content-Encoding: gzip
</FilesMatch>
RewriteEngine on
rewritecond %{HTTP:accept-encoding} (gzip.*)
rewritecond %{REQUEST_FILENAME} !^.+\.gz$
rewritecond %{REQUEST_FILENAME}.gz -f
rewriterule ^(.+) $1.gz [L]
This works fine in FF and Chrome, but in IE8 the gzipped content is displayed like text.
You could simply activate MultiViews and let Apache do the rest:
Options +MultiViews
Then if the client accepts compression it will automatically send the appropriate file if existing (see Note on hyperlinks and naming conventions).
精彩评论