2017-09-25 29 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>