使用多个参数查询字符串重定向 htaccess

redirect with multiple parameter query strings htaccess

我想用多个参数重定向 url 并重命名参数键:

来自

 www.site.it/index.php?par1=1&lang=en_US

 www.site.com/index.php?parameter1=1&languages=en_US

我试过这个:

RewriteCond %{QUERY_STRING} par1=([0-9]+)
RewriteCond %{QUERY_STRING} lang=en_US
RewriteRule ^index.php site.com/index.php?parameter1=&lang=en_US [R=301,L]

但是失败了。

您可以使用:

RewriteCond %{QUERY_STRING} par1=(\d+)&lang=([^&]+)
RewriteRule ^index\.php http://www.example.com/index.php?parameter=%1&languages=%2 [R,L]

%1%2 是对查询字符串 regex

中捕获组的引用