在wordpress多站点上,特定301从domain1重定向到domain2

时间:2014-02-26 10:21:16

标签: wordpress .htaccess mod-rewrite redirect

我有一个WP网络安装。我想将domain1.com上的blog1迁移到domain2.com上的blog2。 这里没什么难的,但是当它迁移时

  • domain1.com/articles/YYYY/到domain2.com/YYYY
  • (或domain1.com/articles/YYYY/MM/到domain2.com/YYYY/MM/)
  • 和domain1.com/articles/YYYY/MM/DD/my-article-title to domain2.com/my-article-title,

我搞乱了RewriteCond和RewriteRules ......

我怎样才能实现它?

这是我在WP网络上的.htaccess

SetEnv PHP_VER 5
SetEnv REGISTER_GLOBALS 0

# Full redirect from domain1 to domain2
# it works if uncommented but it's not exactly what i want
#RewriteCond %{HTTP_HOST} ^(www\.)?domain1.com [NC]
#RewriteRule ^(.*)$ http://domain2.com/$1 [R=301,L]

# WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]

感谢您的时间。

注意:blog1和blog2安装都没问题,类似的数据库,文章都在两边工作。问题仅在301上。

1 个答案:

答案 0 :(得分:0)

这应该将domain1.com/articles/YYYY/更改为domain2.com/YYYYdomain1.com/articles/YYYY/MM/更改为domain2.com/YYYY/MM/

RewriteEngine On
RewriteRule ^articles/(.*)$ http://www.domain2.com/$1 [L,R=301]

编辑: 要重定向到http://www.domain2.com/arctives/YYY/MM/DD

RewriteEngine On
RewriteRule ^articles/(.*)$ http://www.domain2.com/articles/$1 [L,R=301]