无法匹配 mod_rewrite 中的 %2F
我有一组重写规则(在 .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
时,我得到了我期望的结果:list.php 是在 $_GET['search']
中使用 foo,bar
和 foo/bar
调用。
但如果我输入 myserver.com/list/foo%2Fbar
,似乎规则不匹配!相反,我收到 404 错误。这里会发生什么? Apache 2.2.14,如果有的话。
(我在 Firefox 和 Chrome 中尝试过,结果相同——当然,这可能是浏览器出现问题)。
I have a set of rewrite rules (in a .htaccess) something like this:
RewriteRule ^list/vendor/(.*)$ list.php?vendor=$1
RewriteRule ^list/product/(.*)$ list.php?product=$1
RewriteRule ^list/(.*)$ list.php?search=$1
(I don't think the first two are relevant to my question, though).
When I type in myserver.com/list/foo%2Cbar
or even myserver.com/list/foo/bar
, I get the results I expect: list.php is called with foo,bar
and foo/bar
in $_GET['search']
.
But if I type in myserver.com/list/foo%2Fbar
, it seems that the rule doesn't match! I get a 404 error instead. What can be going on here? Apache 2.2.14, if it matters.
(I tried in Firefox and Chrome, same results -- but it could be the browser acting up, of course).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊,我找到了... Apache 选项
AllowEncodedSlashes
,不能按目录或从 .htaccess 设置,默认情况下处于关闭状态。
如果我无法让托管人员在我的虚拟服务器中打开它,则需要构建解决方法。
Bah, I found it... Apache option
AllowEncodedSlashes
, which cannot be set per directory or from .htaccess, and which is Off by default.Build-a-workaround time, if I can't get the hosting guys to turn it on in my virtual server.