Rewrite Query String

后端 未结 2 1692
我在风中等你
我在风中等你 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条回答
  •  旧时难觅i
    2020-12-21 16:18

    The $n only refer to the matches of the RewriteRule directive. Use %n to reference the matches of the corresponding RewriteCond directive.

    Additionally you need to specify an empty query for the substitution. Otherwise the original query will be used.

    And if you want to have the rest of the query to stay intact, use this rule:

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

提交回复
热议问题