0

我想对一些具有参数的旧 URL 直接执行简单的 301。

例如

redirect 301 /display.php?id=2 http://www.url.com.au/about/
redirect 301 /display.php?id=4 http://www.url.com.au/news/

我对 .htaccess 的经验是有限的。使上述重定向真正起作用的最简单和最正确的方法是什么。

4

1 回答 1

1

鉴于您没有其他可能会干扰此规则的规则,这应该可行:

RewriteCond %{QUERY_STRING} ^id=2$
RewriteRule ^display.php$ /about/ [R=301,L]

RewriteCond %{QUERY_STRING} ^id=4$
RewriteRule ^display.php$ /news/ [R=301,L]

如果域不是同一个域,那么您可以包括完整的限定域,如下所示:

RewriteCond %{QUERY_STRING} ^id=2$
RewriteRule ^display.php$ http://www.url.com.au/about/ [R=301,L]
于 2013-07-31T20:42:50.443 回答