Mod 重写问题 - 将参数转发到新参数名称
我已经在 MAMP 上测试了以下 Mod Rewrite,但由于某种原因,它在 LAMP 上失败了。 知道我做错了什么吗?
RewriteEngine on
RewriteCond %{QUERY_STRING} ^newParamA=(.*)&newParamB=([0-9]*)$
RewriteRule ^newfolder/newsubfolder/$ oldfolder/oldsubfolder\.php?oldParamC=%1\&oldParamD=%2 [QSA,L]
这个想法是,诸如此类的查询
http://domain.com/newfolder/newsubfolder/?newParamA=query&newParamB=111
将成功映射到:
http://domain.com/oldfolder/oldsubfolder/?oldParamC=query&oldParamD=111
I've tested the following Mod Rewrite on MAMP, but for some reason, it fails on LAMP. Any idea of what I am doing wrong?
RewriteEngine on
RewriteCond %{QUERY_STRING} ^newParamA=(.*)&newParamB=([0-9]*)$
RewriteRule ^newfolder/newsubfolder/$ oldfolder/oldsubfolder\.php?oldParamC=%1\&oldParamD=%2 [QSA,L]
The idea is that a query such as
http://domain.com/newfolder/newsubfolder/?newParamA=query&newParamB=111
will successfully map to:
http://domain.com/oldfolder/oldsubfolder/?oldParamC=query&oldParamD=111
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
回答 Gumbo 的评论(您使用相同的配置吗)
是的 - 最新版本的 Apache,启用了 mod_rewrite - 似乎它不喜欢 RewriteCond - 如果我注释掉,至少路径重定向有效。 当我取消注释 RewriteCond 时,出现“未找到”错误。
In answer to Gumbo's comment (Are you using the same config)
Yep - latest version of Apache, with mod_rewrite enabled - It seems that it doesn't like the RewriteCond - if I comment that out, at least the path redirect works. When I uncomment the RewriteCond, I get "Not found" error.
我目前不知道什么会导致这种行为。 但你可以尝试其中之一:
甚至:
I currently don’t know what could cause this behavior. But you could try one of these:
Or even: