htaccess 删除查询字符串然后重定向

htaccess remove query string and then redirect

我需要根据查询字符串重定向 url 并且需要在重定向时删除查询字符串。

Source url: http://www.example.com/?id=15&L=1&link=androidapp

Target url: http://www.example.com/test.php&id=15&L=1

'?id=' 是一个动态参数。每次都会更改。

我写了以下条件。它重定向,但我没有获得所需的目标 url.

RewriteCond %{QUERY_STRING} link=androidapp 
RewriteRule ^(.*)$ http://www.example.com/test.php? [R=301,L]

请帮帮我

你可以使用这个.htaccess:

RewriteCond %{QUERY_STRING} id=(\d+)&L=(\d+)&link=androidapp [NC]
RewriteRule ^ test.php?id=%1&L=%2 [R=301,L]