初学者的Apache的mod_rewrite援助 [英] Beginner's apache mod_rewrite assistance
本文介绍了初学者的Apache的mod_rewrite援助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我没有真正熟悉Apache 的mod_rewrite
。
I am not really familiar with apache mod_rewrite
.
我有URL参数,如 {}域/index.php?blog=5
我只是想让它 {}域/home.php?client=5
是不是因为它的声音和简单的任务谁能帮助?
Is it a task as simple as it sounds and can anyone help?
推荐答案
这似乎是pretty简单,说实话 - 一旦你得到你的头到的mod_rewrite
,它并不复杂。
That seems pretty simple, to be honest — once you get your head into mod_rewrite
, it's not that complex.
这听起来像你想添加
RewriteEngine on
RewriteRule ^/index.php?blog=(.+)$ /home.php?client=$1
你的配置。
一些注意事项:
- 如果你把这个在
的.htaccess
文件,然后删除/
从重写规则
行。 - 如果你想使这个不区分大小写,添加
[NC]
到同一行的末尾。 - 如果您希望用户看到的URL变化(所以发送
302找到
重定向到浏览器),然后加入[R]
到重写规则
行的末尾。 - 如果要同时使用
302找到
并为URL是区分大小写的,二者结合起来指导为[NC,R]
在重写规则
行的末尾。
- If you are putting this in a
.htaccess
file, then remove the/
from theRewriteRule
line. - If you want to make this case-insensitive, add
[NC]
to the end of that same line. - If you want users to see the URL change (so sending a
302 Found
redirection to the browser), then add[R]
to the end of theRewriteRule
line. - If you want both a
302 Found
and for the URL to be case-sensitive, combine the two instructions as[NC,R]
at the end of theRewriteRule
line.
这绝对是值得一读的 的mod_rewrite
文档,但上面的规则应该是所有你需要的用例。
It's definitely worth reading the mod_rewrite
docs, but the rule above should be all you need for this use-case.
这篇关于初学者的Apache的mod_rewrite援助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文