0

我在 Windows 7 上配置了 Apache/2.2.17 服务器,在 .htaccess 中配置了 mod deflate

SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ \
no-gzip dont-vary
SetEnvIfNoCase Request_URI \
 \.(?:exe|t?gz|zip|bz2|sit|rar)$ \
no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

但是除了视频没有在 Flowplayer 中播放之外,一切都很好,所以我在 .htaccess 中更改(在 exclude from gzip compression 中添加了 SWF)

SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ \
no-gzip dont-vary
SetEnvIfNoCase Request_URI \
 \.(?:exe|t?gz|zip|bz2|sit|rar|swf)$ \
no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

现在视频在除 IE 之外的所有浏览器中的 flowplayer 中播放。

我希望正确的配置也能在 IE 中工作。

4

1 回答 1

0

以下配置有效。

# force deflate for mangled headers 
# developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$   ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
 </IfModule>
</IfModule>

# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
<IfModule filter_module>
 FilterDeclare   COMPRESS
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/html
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/css
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/plain
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/xml
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/x-component
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/javascript
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/json
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xml
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xhtml+xml
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/rss+xml
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/atom+xml
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/vnd.ms-fontobject
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/svg+xml
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/x-font-ttf
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $font/opentype
 FilterChain     COMPRESS
 FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
</IfModule>

 <IfModule !mod_filter.c>
 # Legacy versions of Apache
 AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
 AddOutputFilterByType DEFLATE application/javascript
 AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
  AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml    application/atom+xml
   AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
 </IfModule>
  </IfModule>
于 2012-01-23T15:25:52.160 回答