简体   繁体   中英

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$">
  ForceType 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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM