2

I've got another redirect I'm having some issues on.

While it DOES redirect, once the page loads, the rule somehow adds everything after the question mark at the end of the URL.

So, badexample.com would show up as badexample.com/?p=1297

Here's the rule:

RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^/wordpress/\?p=1297$
RewriteRule ^.*$ http://www.badexample.com [R=301,L]

Any ideas on this one?

4

1 回答 1

3

如果您不希望在重写的 URL 之后出现查询,理论上您可以使用[QSD]标志(我认为它代表查询字符串删除)。但是在实践中,根据我的经验,它有时效果不太好。

相反,将一个空查询字符串添加到您的新 url:

RewriteRule ^.*$ http://www.badexample.com? [R=301,L]

这将停止添加任何其他查询字符串。

于 2013-07-10T16:08:50.033 回答