htaccess url 重写带问号
我在 .htaccess
中遇到问题,特别是在重定向方面。
我想重写这个 url:
http://www.domain.com/?mod=country
to
http://www.domain.com/country
我已经尝试过这个 .htaccess
代码:
RewriteEngine on
RewriteRule ^\?mod=(.*)$ $1
我尝试在没有问号字符的情况下对其进行处理,并且它工作正常。 我已经逃脱了问号,因为它是特殊字符的一部分,但我仍然无法让它工作。
你能告诉我我错过了什么吗?
I'm having a problem in .htaccess
, specifically on redirection.
I wanted to rewrite this url:
http://www.domain.com/?mod=country
to
http://www.domain.com/country
I already tried this .htaccess
code:
RewriteEngine on
RewriteRule ^\?mod=(.*)$ $1
I tried working on it without the question mark character and it works fine.
I have escaped the question mark because it's part of the special characters, but still, I couldn't get it work.
Can you tell what I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
直接将您的要求转化为重写规则:
但您可能想要更灵活的东西,例如:
这些规则适用于您的域的根。
如果您想进行外部重定向,请将
R
标志添加到重写规则中。Directly translating your requirements to rewrite rules:
But you probably want something more flexible like:
These rules apply to the root of your domain.
If you want to do an external redirect add the
R
flag to the rewrite rule.