2017-09-25 32 views
0

以下代码在.htaccess中导致500内部服务器错误。 我已经尝试更新到Apache 2.4的代码,但似乎我在某个地方犯了一个错误。IfModule filter_module内部服务器错误Apache 2.2到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内部服务器错误:

​​

任何帮助将不胜感激!

谢谢。 :)

回答

0

由于某些原因apache 2.4不支持更紧凑的代码! 反正文件,如果有人面临着同样的问题,这里是WORKING解决方法:(只是模仿的变化)

<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>