无法匹配 mod_rewrite 中的 %2F [英] Cannot match %2F in mod_rewrite

查看:22
本文介绍了无法匹配 mod_rewrite 中的 %2F的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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).

当我输入 myserver.com/list/foo%2Cbar 甚至 myserver.com/list/foo/bar 时,我会得到我期望的结果:list.php 在 $_GET['search'] 中使用 foo,barfoo/bar 调用.

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'].

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

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.

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

(I tried in Firefox and Chrome, same results -- but it could be the browser acting up, of course).

推荐答案

呸,我找到了... 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.

这篇关于无法匹配 mod_rewrite 中的 %2F的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆