无法匹配 mod_rewrite 中的 %2F

问题描述 投票:0回答:1

我有一组重写规则(在 .htaccess 中),如下所示:

RewriteRule ^list/vendor/(.*)$ list.php?vendor=$1
RewriteRule ^list/product/(.*)$ list.php?product=$1
RewriteRule ^list/(.*)$ list.php?search=$1

(不过,我认为前两个与我的问题无关)。

当我输入

myserver.com/list/foo%2Cbar
甚至
myserver.com/list/foo/bar
时,我得到了我期望的结果:用
foo,bar
foo/bar
中的
$_GET['search']
调用 list.php。

但是如果我输入

myserver.com/list/foo%2Fbar
,似乎规则不匹配!相反,我收到 404 错误。这里会发生什么? Apache 2.2.14,如果重要的话。

(我在 Firefox 和 Chrome 中尝试过,结果相同——但当然也可能是浏览器出现问题)。

mod-rewrite url-rewriting apache2
1个回答
18
投票

呸,我找到了... Apache 选项

AllowEncodedSlashes
,它不能按目录或从 .htaccess 设置,默认情况下处于关闭状态。

如果我无法让托管人员在我的虚拟服务器中打开它,则需要构建解决方法时间。

© www.soinside.com 2019 - 2024. All rights reserved.