AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 41265
In Process
Malfist
Malfist
Asked: 2009-07-16 12:21:01 +0800 CST2009-07-16 12:21:01 +0800 CST 2009-07-16 12:21:01 +0800 CST

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

  • 772

我正在尝试在我的网络服务器上启用 Gzip,但没有成功。无论如何,我现在应该有,我以前做过,但成功离我很远。

我的 httpd.conf 中有这个

<位置“C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/bt/web”>
    # 插入过滤器
    SetOutputFilter DEFLATE

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

    # Netscape 4.06-4.08 还有一些问题
    BrowserMatch ^Mozilla/4\.0[678] 无 gzip

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

    # 注意:由于 Apache 2.0.48 之前的 mod_setenvif 中的一个错误
    # 上面的正则表达式不起作用。您可以使用以下
    # 获得预期效果的解决方法:
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

    # 不压缩图片
    SetEnvIfNoCase Request_URI \
    \.(?:gif|jpe?g|png)$ no-gzip 不变化

    # 确保代理不会提供错误的内容
    标头追加 Vary User-Agent env=!dont-vary
</位置>

和

<IfModule mod_deflate.c>
<FilesMatch "\.(js|css|html|htm)$">
SetOutputFilter DEFLATE
</文件匹配>
</IfModule>

mod_deflate 已启用。

我究竟做错了什么?

windows apache-2.2
  • 1 1 个回答
  • 2843 Views

1 个回答

  • Voted
  1. Freddy
    2009-07-18T13:51:24+08:002009-07-18T13:51:24+08:00

    第一个问题是您拥有带有文件系统目录的元素......

    这是来自 Apache 手册:

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

    当我在 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>
    
    • 1

相关问题

  • 您最喜欢的云计算提供商是什么?[关闭]

  • Vanilla Powershell 是否足以成为 Windows 和 DB 服务器管理员的语言?

  • 为什么添加新驱动器后我的磁盘驱动器访问速度如此之慢?

  • 在 Windows Server 2003 下使用 wscipt 从 .asp 文件运行 .exe

  • 最佳混合环境(OS X + Windows)备份?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve