Rewrite Query String

后端 未结 2 1694
我在风中等你
我在风中等你 2020-12-21 16:08

I have this URL:

oldsite.com/profile.php?uid=10

I would like to rewrite it to:

newsite.com/utenti/10

How can I do that?

2条回答
  •  甜味超标
    2020-12-21 16:19

    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]
    

提交回复
热议问题