阿帕奇的.htaccess:如何重写反斜线与斜线在Firefox?斜线、重写、阿帕奇、Firefox

2023-09-02 00:42:14 作者:美少女壮士

如何重写反斜线''用斜线/在Firefox?

Chrome浏览器,IE,Safari浏览器,Opera有打造的浏览器重写反斜线与斜线。 但Firefox 3.6.13回报的 404错误页面的。

 #为什么火狐会返回404错误页面?
的RewriteCond%{REQUEST_URI}(。*)\(。*)
重写规则。*%1 /%2 [R = 301,L]
 

解决方案

这是Apache和FF的错误,的 https://issues.apache.org/bugzilla/show_bug.cgi?id=35256 希望这会固定在马上的功能。

      AllowEn codedSlashes应该真正做到上的默认情况下,甚至可能去precated。 ...   无处RFC文档是一个反斜杠()列为保留字符。因此,一个%5C   应永远是德codeD一样的%7E 被转换为波浪号(〜)。   

要解决它在Apache: 添加 AllowEn codedSlashes在虚拟主机的httpd-vhosts.conf或httpd.conf中,和.htaccess:

  RewriteEngine叙述上
的RewriteCond%{REQUEST_URI} ^(。*)\(。*)$
重写规则。*%1 /%2 [R = 301,NC,L]
 
六百万军队报废,总统带头逃跑 真乃二战中最令人无法理解的国家

How to rewrite backslash''with slash'/'on Firefox?

Chrome, IE, Safari, Opera has build browser rewrite backslash with slash. But Firefox 3.6.13 returns 404 error page.

# Why Firefox returns 404 error page?
RewriteCond %{REQUEST_URI} (.*)\(.*)
RewriteRule .* %1/%2 [R=301,L]

解决方案

It is Apache and FF bug, https://issues.apache.org/bugzilla/show_bug.cgi?id=35256 Hopefully it'll be fixed in soon feature.

AllowEncodedSlashes should really be "on" by default and probably even deprecated. ... Nowhere the RFCs is a backslash () listed as a reserved character. Therefore a %5C should always be decoded the same as %7E is converted to a tilde (~).

To solve it on Apache: add AllowEncodedSlashes On in VirtualHost httpd-vhosts.conf or httpd.conf, and .htaccess:

RewriteEngine On 
RewriteCond %{REQUEST_URI} ^(.*)\(.*)$
RewriteRule .* %1/%2 [R=301,NC,L]