Windows Server 2008 上 helicon ape 的正则表达式问题
我有以下重写规则:
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\\.php\?(.*) /$2.php?shop=$1&$3 [NC,L]
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\\.php /$2.php?shop=$1 [NC,L]
RewriteRule ^([a-zA-Z0-9]*)/$ /index.php?shop=$1 [L,NC]
RewriteRule ^([a-zA-Z0-9]*)$ /index.php?shop=$1 [L,NC]
结果应该重定向以下内容:
www.site.com/Sells
-> /index.php?shop=Sells [works]
www.site.com/Sells/menu.php?Cat=1
-> /menu.php?shop=Sells&Cat=1 [failing]
-> /menu.php?shop=Sells [which is 'wrong']
最后一个示例应该通过重写[1]匹配...
我已经测试了规则ape 附带的正则表达式测试器发现转义 ?
和 .
似乎不起作用。我有点困惑,很感激任何人 可以解释为什么这种转义不起作用。
预先表示感谢。
I have the following rewrite rules:
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\\.php\?(.*) /$2.php?shop=$1&$3 [NC,L]
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\\.php /$2.php?shop=$1 [NC,L]
RewriteRule ^([a-zA-Z0-9]*)/$ /index.php?shop=$1 [L,NC]
RewriteRule ^([a-zA-Z0-9]*)$ /index.php?shop=$1 [L,NC]
The result of which should redirect the following:
www.site.com/Sells
-> /index.php?shop=Sells [works]
www.site.com/Sells/menu.php?Cat=1
-> /menu.php?shop=Sells&Cat=1 [failing]
-> /menu.php?shop=Sells [which is 'wrong']
The last example should get matched by rewrite [1]...
I have tested the rules with the regex tester shipped with ape and found that escaping ?
and .
don't seem to work. I am a little flummoxed and would appreciate anyone who
could shed some light on why this escaping is not working.
Loads of thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
逃避太多了。将
\\.php
更改为\.php
。Too much escaping. Change
\\.php
to\.php
.你似乎逃避了“逃避”的意思。 (你有 \. ,它被读作 \ 和任何字母/符号)
You seem to escape the \ that is meant to escape the . (you have \. which is read as \ and any letter/symbol)
QSA 标志丢失!它附加了查询字符串,但我忘了将其放入!
我作为预览添加的双斜杠没有显示单斜杠!
QSA flag was missing! it appends the query string and I forgot to put it in!!!
The double slashes I added as preview was not showing the single ones!