.htaccess mod_filter text/html gzip在apache 2.4上

.htaccess mod_filter text/html gzip在apache 2.4上,.htaccess,gzip,mod-filter,.htaccess,Gzip,Mod Filter,我正在尝试为内容类型启用压缩:text/html 我正在运行Apache2.4,我发现不再使用mod_gzip和mod_deflate,而是应该使用mod_过滤器 经过长时间的谷歌会话和多次尝试/失败后,我决定在这里试试运气 我可以确认mod_filter和mod_deflate都已启用 我试图添加到.htaccess的组合: <IfModule mod_filter.c> AddOutputFilterByType DEFLATE text/html </IfModule

我正在尝试为内容类型启用压缩:text/html

我正在运行Apache2.4,我发现不再使用mod_gzip和mod_deflate,而是应该使用mod_过滤器

经过长时间的谷歌会话和多次尝试/失败后,我决定在这里试试运气

我可以确认mod_filter和mod_deflate都已启用

我试图添加到.htaccess的组合:

<IfModule mod_filter.c>
 AddOutputFilterByType DEFLATE text/html
</IfModule>

<IfModule mod_deflate.c>
    <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>

    <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE text/html
    </IfModule>
</IfModule>

<IfModule filter_module>
FilterDeclare   COMPRESS
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/html'"
FilterChain     COMPRESS  
FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
</IfModule>

AddOutputFilterByType DEFLATE text/html
SetEnvIfNoCase^((gzip | deflate)\s*,?\s*)+|[X~-]{4,13}$有接受编码
RequestHeader追加接受编码“gzip,deflate”env=HAVE_Accept-Encoding
AddOutputFilterByType DEFLATE text/html
FilterDeclare压缩
FilterProvider COMPRESS DEFLATE“%{Content_Type}='text/html'”
过滤链压缩
过滤器协议压缩放气变化=是;byteranges=否
基本上我可以在网上找到任何东西。但什么都不管用

我一直得到同样的结果:

请求标头: 接受:text/html、application/xhtml+xml、application/xml;q=0.9,图像/webp,/;q=0.8 接受编码:gzip、deflate、sdch

响应标题: 内容类型:text/html;charset=utf-8(不带内容编码:gzip头)

使用AWSEC2实例

找到了使用httpd.conf的解决方法。如果有人觉得有用的话,我就把这个放在这里

只需确认-AddOutputFilterByType DEFLATE。。。适用于Apache2.4