简体   繁体   English

Gzip压缩的网站无法与IE一起使用

[英]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). 在我的网站上,我找到了一些最常用和最大的文件的压缩副本(因为我的托管不允许使用gzip压缩模块)。

I have inserted rewrite rules in the htaccess file to send the gzipped copies when available, like this: 我在htaccess文件中插入了重写规则,以便在可用时发送压缩后的副本,如下所示:

<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. 这在FF和Chrome中可以正常工作,但是在IE8中,压缩后的内容显示为文本。

You could simply activate MultiViews and let Apache do the rest: 您可以简单地激活MultiViews并让Apache完成其余工作:

Options +MultiViews

Then if the client accepts compression it will automatically send the appropriate file if existing (see Note on hyperlinks and naming conventions ). 然后,如果客户端接受压缩,它将自动发送适当的文件(如果存在)(请参阅有关超链接和命名约定的注释 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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