重写查询字符串

col*_*rco 2 apache mod-rewrite query-string

我有这个网址:

oldsite.com/profile.php?uid=10

我想把它重写为:

newsite.com/utenti/10

我怎样才能做到这一点?

更新:我写了这个:

RewriteCond %{QUERY_STRING} ^uid=([0-9]+)$
RewriteRule ^profile\.php$ http://www.newsite.com/utenti/$1 [R=301,L]

但$ 1匹配完整的查询字符串而不仅仅是用户ID.

Vin*_*vic 6

要在重写条件中使用匹配项,您必须使用%1而不是$ 1.另外,如果你想删除查询字符串的其余部分,你必须附加一个?

RewriteCond %{QUERY_STRING} ^uid=([0-9]+)$
RewriteRule ^profile\.php$ http://www.newsite.com/utenti/%1? [R=301,L]