初学者 apache mod_rewrite 帮助
我不太熟悉 apache mod_rewrite
。
我有 url 参数,例如 {domain}/index.php?blog=5
我只是想让它 {domain}/home.php?client=5
是吗这项任务听起来很简单,有人可以帮忙吗?
I am not really familiar with apache mod_rewrite
.
I have url parameters such as {domain}/index.php?blog=5
I simply want to make it {domain}/home.php?client=5
Is it a task as simple as it sounds and can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下可能有效,请尝试一下
The following might work, give it a try
说实话,这看起来很简单——一旦你深入了解 mod_rewrite,它就没有那么复杂了。
听起来您想添加
到您的配置中。
一些注意事项:
.htaccess
文件中,请从RewriteRule
行中删除/
。[NC]
添加到同一行的末尾。302 Found
重定向),请将[R]
添加到RewriteRule< 的末尾/代码>行。
302 Found
和 URL 区分大小写,请将这两个指令组合为RewriteRule 末尾的
行。[NC,R]
绝对值得阅读
mod_rewrite
文档,但上面的规则应该是这个用例所需的全部。That seems pretty simple, to be honest — once you get your head into
mod_rewrite
, it's not that complex.It sounds like you want to add
to your configuration.
Some caveats:
.htaccess
file, then remove the/
from theRewriteRule
line.[NC]
to the end of that same line.302 Found
redirection to the browser), then add[R]
to the end of theRewriteRule
line.302 Found
and for the URL to be case-sensitive, combine the two instructions as[NC,R]
at the end of theRewriteRule
line.It's definitely worth reading the
mod_rewrite
docs, but the rule above should be all you need for this use-case.