繁体   English   中英

IfModule filter_module内部服务器错误Apache 2.2至2.4

[英]IfModule filter_module Internal Server Error Apache 2.2 to 2.4

.htaccess中的以下代码导致500 Internal Server Error。 我尝试将代码更新为Apache 2.4,但似乎在某个地方犯了一个错误。

请告知以下导致此错误的代码有什么问题:

<IfModule filter_module>
    FilterDeclare   COMPRESS
    FilterProvider  COMPRESS  DEFLATE "%{Content-Type} = text/(html|css|javascript|plain|x(ml|-component))"
    FilterProvider  COMPRESS  DEFLATE "%{Content-Type} = application/(javascript|json|xml|x-javascript)"
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  change=yes;byteranges=no
</IfModule>

也尝试过此代码,但不起作用:

<IfVersion >= 2.4>
<IfModule filter_module>
    FilterDeclare   COMPRESS
    FilterProvider  COMPRESS  DEFLATE "%{Content-Type} =~ 'text/(html|css|javascript|plain|x(ml|-component))'"
    FilterProvider  COMPRESS  DEFLATE "%{Content-Type} =~ 'application/(javascript|json|xml|x-javascript)'"
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  change=yes;byteranges=no
</IfModule>
</IfVersion>

<IfVersion <= 2.2>
<IfModule filter_module>
    FilterDeclare   COMPRESS
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  change=yes;byteranges=no
</IfModule>
</IfVersion>

经过测试后,这两行是导致500 Internal Server Error的原因:

    FilterProvider  COMPRESS  DEFLATE "%{Content-Type} =~ 'text/(html|css|javascript|plain|x(ml|-component))'"
    FilterProvider  COMPRESS  DEFLATE "%{Content-Type} =~ 'application/(javascript|json|xml|x-javascript)'"

任何帮助,将不胜感激!!

谢谢。 :)

由于某种原因,Apache 2.4不支持更紧凑的代码! 无论如何获取文档,如果有人遇到相同的问题,这里是工作解决方案:( 只需模仿更改)

<IfVersion >= 2.4>
<IfModule filter_module>
    FilterDeclare   COMPRESS
    FilterProvider  COMPRESS  DEFLATE "%{CONTENT_TYPE} =~ m|^text/html|"
    FilterProvider  COMPRESS  DEFLATE "%{CONTENT_TYPE} =~ m|^text/css|"
    FilterProvider  COMPRESS  DEFLATE "%{CONTENT_TYPE} =~ m|^text/javascript|"
    FilterProvider  COMPRESS  DEFLATE "%{CONTENT_TYPE} =~ m|^text/plain|"
    FilterProvider  COMPRESS  DEFLATE "%{CONTENT_TYPE} =~ m|^text/xml|"
    FilterProvider  COMPRESS  DEFLATE "%{CONTENT_TYPE} =~ m|^text/x-component|"
    FilterProvider  COMPRESS  DEFLATE "%{CONTENT_TYPE} =~ m|^application/javascript|"
    FilterProvider  COMPRESS  DEFLATE "%{CONTENT_TYPE} =~ m|^application/json|"
    FilterProvider  COMPRESS  DEFLATE "%{CONTENT_TYPE} =~ m|^application/xml|"
    FilterProvider  COMPRESS  DEFLATE "%{CONTENT_TYPE} =~ m|^application/x-javascript|"
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  change=yes;byteranges=no
</IfModule>
</IfVersion>

<IfVersion <= 2.2>
<IfModule filter_module>
    FilterDeclare   COMPRESS
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type /text/(html|css|javascript|plain|xml|x-component)/
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  change=yes;byteranges=no
</IfModule>
</IfVersion>

暂无
暂无

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

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