问题
In htaccess file the following works
redirect 302 /old.php http://somesite.com/new.php
but following fails
redirect 302 /old.php?this=that http://somesite.com/new.php
I think it's because the second version contains a query string. How can we redirect URLs like that?
Please note the destination URL format is different so it cannot be an automated rule, so I need to write the custom URLs that users will be redirected to.
I found a similar question with replies here, but the proposed solutions do not work:
.htaccess not able to redirect url
Thank you
回答1:
You may use this rule as topmost rule in site root .htaccess of old domain:
RewriteEngine On
RewriteCond %{QUERY_STRING} (?:^|&)this=that(?:&|$) [NC]
RewriteRule ^old\.php$ http://somesite.com/new.php? [R=301,L]
来源:https://stackoverflow.com/questions/62423283/302-redirect-url-with-parameters