0

我正在将一个网站从 Drupal 迁移到 WordPress。许多网站的页面在 Google 和 Bing 中被索引为http://www.example.com/?q=webpage-name我希望使用 301 重定向将这些页面重定向到格式为http 的新网页: //www.example.com/webpage-name

我试过了:

Redirect 301 /?q=services http://www.example.com/services

我也试过:

Redirect 301 http://www.example.com/?q=services http://www.example.com/services

上述两个示例都重定向到主页而不是服务页面。

4

1 回答 1

2

我相信重定向不考虑查询字符串部分,这就是它失败的原因,试试这个:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^q=services$
RewriteRule ^ /services [R=301,L]

您还可以像这样制作一种包罗万象的东西:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^q=(.*)$
RewriteRule ^ /%1 [R=301,L]
于 2013-07-28T02:16:14.717 回答