在htaccess文件中,以下工作
redirect 302 /old.php http://somesite.com/new.php
但跟随失败
redirect 302 /old.php?this=that http://somesite.com/new.php
我认为是因为第二个版本包含查询字符串。我们如何重定向这样的URL?
请注意,目标URL格式不同,因此它不能成为自动规则,因此我需要编写用户将重定向到的自定义URL。
我在这里找到了类似的问题并得到了答复,但是建议的解决方案不起作用:
.htaccess not able to redirect url
谢谢
答案 0 :(得分:1)
您可以将此规则用作旧域的站点根.htaccess中的最高规则:
RewriteEngine On
RewriteCond %{QUERY_STRING} (?:^|&)this=that(?:&|$) [NC]
RewriteRule ^old\.php$ http://somesite.com/new.php? [R=301,L]