Apache重写规则,使漂亮的url


Apache rewrite rule to make pretty URLs

我想保持我的url漂亮。

假设我们有URL:

severhost.com/team/4325

在team.php文件中,我希望4325填充为$_GET["id"]

我有这样的重写规则:

RewriteRule ^/?team/([0-9]+)$ team.php?id=$1 [R]

但是这实际上把浏览器中的URL改为:

severhost.com/team.php?id=4325

我希望浏览器中的URL保持severhost.com/team/4325

规则末尾的[R]标志表示重定向。所以你要做的是告诉它重定向,而不是重写规则。您可能只想将其更改为[L]

RewriteRule ^/?团队/([0 - 9]+)team.php美元吗?id = 1美元(PS)

需要设置为[PS]