内容编码尝试在Apache上使用GZip时出错

我正尝试在我的networking服务器上启用Gzip,但没有成功。 无论如何,我现在应该已经做到了,但是成功却无法摆脱我。

我在我的httpd.conf中有这个

 <Location:C:/ Program Files(x86)/ Apache Software Foundation / Apache2.2 / htdocs / bt / web“>
     #插入filter
     SetOutputFilter DEFLATE

     #Netscape 4.x有一些问题...
     BrowserMatch ^ Mozilla / 4 gzip-only-text / html

     #Netscape 4.06-4.08有更多的问题
     BrowserMatch ^ Mozilla / 4 \ .0 [678] no-gzip

     #MSIE伪装成Netscape,但没关系
     #BrowserMatch \ bMSIE!no-gzip!gzip-only-text / html

     #注意:由于mod_setenvif中的错误,直到Apache 2.0.48
     #上述正则expression式不起作用。 您可以使用以下内容
     #解决方法,以获得预期的效果:
     BrowserMatch \ bMSI [E]!no-gzip!gzip-only-text / html

     #不要压缩图像
     SetEnvIfNoCase Request_URI \
     \。(?: gif | jpe?g | png)$ no-gzip dont-vary

     #确保代理不传递错误的内容
    头附加Vary User-Agent env =!不要变化
 </位置> 

 <IfModule mod_deflate.c>
 <FilesMatch“\。(js | css | html | htm)$”>
 SetOutputFilter DEFLATE
 </ FilesMatch>
 </ IfModule>configuration

mod_deflate已启用。

我究竟做错了什么?

第一个问题是你有从文件系统目录的元素…

这是从Apache手册:

何时使用<Location> 使用<Location>将指令应用于文件系统之外的内容。 对于存在于文件系统中的内容,使用<Directory><Files> 一个例外是<Location /> ,这是一个将configuration应用到整个服务器的简单方法。

当我在Apache上设置mod_deflate时,我使用这个设置:

 # -------------------------------------------------------- # Deflate Module Configuration # -------------------------------------------------------- <IfModule deflate_module> # Set the location to webservers root <Location /> # Insert the filters SetOutputFilter DEFLATE # Netscape 4.x has some problems BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary # Make sure to never zip binaries (ie6 and chrome has issues with this.) 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 </Location> # Enable mod_deflate logging by uncommenting these lines #DeflateFilterNote Input instream #DeflateFilterNote Output outstream #DeflateFilterNote Ratio ratio #LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate #CustomLog logs/deflate_log deflate </IfModule>