为什么此 mod_rewrite 表达式不能正确附加现有查询字符串?
我是 mod_rewrite 方面的真正新手,所以请不要笑。我正在使用这个工具进行测试: http://civilolydnad.se/projects/rewriterule/
基本上我想重写
http://hostname/spanish/whatever/
为
http://hostname/whatever/?lang=es
这是我能想到的最好的:
RewriteRule ^spanish/(.*)$ $1?lang=es [QSA,L,NC]
这似乎可以工作除非当请求的页面已经有参数时。在这种情况下,
http://hostname/spanish/gallery/photos/?page=2
会被重写为“
http://hostname/spanish/gallery/photos/?page=2?lang=es
有人能帮助这个困惑的新手吗?”非常感谢。
I'm a real newbie regarding mod_rewrite so please don't laugh. I am using this tool for testing: http://civilolydnad.se/projects/rewriterule/
Basically I want to rewrite
http://hostname/spanish/whatever/
into
http://hostname/whatever/?lang=es
Here's the best I could come up with:
RewriteRule ^spanish/(.*)$ $1?lang=es [QSA,L,NC]
which seems to work except when the requested page already has parameters. In that case
http://hostname/spanish/gallery/photos/?page=2
gets rewritten as
http://hostname/spanish/gallery/photos/?page=2?lang=es
Can anyone help this confused newbie? Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上,该工具具有误导性,因为在真实服务器环境中使用时,该规则被证明是正确的(如所写)。感谢大家。
Basically, the tool is misleading, because the rule was proven to be correct, as written, when used on a real server environment. Thanks to all.
像这样的事情应该有帮助。
Something like this should help.