【问题标题】:htaccess FilterProvider giving error 500htaccess FilterProvider 给出错误 500
【发布时间】:2014-04-23 21:12:56
【问题描述】:

我正在使用Apache/2.4.4 (Unix) PHP/5.5.3 OpenSSL/1.0.1e mod_perl/2.0.8-dev Perl/v5.16.3,当我尝试在浏览器中打开此页面时收到错误 500 /xamppfiles/htdocs/wm/frontend/www/ 如果我的错误日志如下。

[Tue Mar 18 17:03:51.923726 2014] [core:alert] [pid 933] [client ::1:51765] /Applications/XAMPP/xamppfiles/htdocs/wm/frontend/www/.htaccess: FilterProvider takes three arguments, filter-name provider-name match-expression

这是我的 htaccess 文件

   # ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------

<IfModule mod_deflate.c>

# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<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>

# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
<IfModule filter_module>
  FilterDeclare   COMPRESS
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/html
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/css
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/plain
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/x-component
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/javascript
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/json
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xhtml+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/rss+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/atom+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/vnd.ms-fontobject
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/svg+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/x-font-ttf
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $font/opentype
  FilterChain     COMPRESS
  FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
</IfModule>

<IfModule !mod_filter.c>
  # Legacy versions of Apache
  AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
  AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
  AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</IfModule>
</IfModule>

我试过了,但也没有运气

<IfVersion >= 2.4.4>
<IfModule filter_module>
  FilterDeclare   COMPRESS
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/html
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/css
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/plain
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/x-component
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/javascript
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/json
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xhtml+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/rss+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/atom+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/vnd.ms-fontobject
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/svg+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/x-font-ttf
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $font/opentype
  FilterChain     COMPRESS
  FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
</IfModule>
</IfVersion>

<IfVersion <= 2.4.4>
<IfModule filter_module>
    FilterDeclare   COMPRESS
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/html'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/css'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/plain'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/x-component'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/javascript'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/json'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/xhtml+xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/rss+xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/atom+xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/vnd.ms-fontobject'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'image/svg+xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'image/x-icon'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/x-font-ttf'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'font/opentype'"
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
</IfModule>
</IfVersion>

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    你的逻辑有问题。您有旧版本使用的 %{Content_Type} 语法,并且两个 IfVersion 条件都将匹配版本 2.4.4,因为您在两个条件上都有“或等于”。

    这应该可行:

    <IfVersion < 2.4.4>
    <IfModule filter_module>
    FilterDeclare   COMPRESS
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/html
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/css
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/plain
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/x-component
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/javascript
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/json
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xhtml+xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/rss+xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/atom+xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/vnd.ms-fontobject
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/svg+xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/x-font-ttf
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $font/opentype
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
    </IfModule>
    </IfVersion>
    
    <IfVersion >= 2.4.4>
    <IfModule filter_module>
    FilterDeclare   COMPRESS
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/html'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/css'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/plain'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/x-component'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/javascript'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/json'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/xhtml+xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/rss+xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/atom+xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/vnd.ms-fontobject'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'image/svg+xml'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'image/x-icon'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/x-font-ttf'"
    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'font/opentype'"
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
    </IfModule>
    </IfVersion>
    

    【讨论】:

    • 实际上,您可以通过将 &lt;IfModule filter_module&gt; 标记放在其他所有内容周围(节省 2 行)并使用额外的 &lt;IfModule version.c&gt; 检查 &lt;IfVersion&gt;-blocks 来确保 IfVersion甚至是可能的(否则会导致另一个错误)。
    • 你拯救了我的一天......!谢谢
    猜你喜欢
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多