重写查询字符串 [英] Rewrite Query String
本文介绍了重写查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个网址:
oldsite.com/profile.php?uid=10
我想将其改写为:
I would like to rewrite it to:
newsite.com/utenti/10
我怎么能这样做?
How can I do that?
更新:我写了这一点:
RewriteCond %{QUERY_STRING} ^uid=([0-9]+)$
RewriteRule ^profile\.php$ http://www.newsite.com/utenti/$1 [R=301,L]
不过$ 1场完整的查询字符串,而不仅仅是用户ID。
But $1 match the full query string and not just the user id.
推荐答案
要在改写条件下使用的比赛,你必须使用%1而不是$ 1。另外,如果你要删除的查询字符串的其余部分,你必须追加?
To use matches in the rewrite conditions, you have to use %1 instead of $1. Also, if you wish to remove the rest of the query string you have to append a ?
RewriteCond %{QUERY_STRING} ^uid=([0-9]+)$
RewriteRule ^profile\.php$ http://www.newsite.com/utenti/%1? [R=301,L]
这篇关于重写查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文