我正在尝试将WP站点上的整个目录重定向到新域上的目录,新域上存在一些子目录例外。
e.g。
Redirect /2012/ to newdomain.com/blog
Redirect /2012/subdirectory to newdomain.com/2012/subdirectory
这就是我的工作:
#blanket redirect with exceptions
RewriteCond %{REQUEST_URI} !^/2012/$
RewriteCond %{REQUEST_URI}
!^/2012/(\/2012\/subdirectory1\/|\/2012\/subdirectory2\/|\/2012\/subdirectory1\/)
RewriteRule ^/?2012/(.+)$ http://www.newdomain.com/blog/ [L,R=301]
#redirecting the exceptions
RewriteCond %{HTTP_HOST} ^old-domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.old-domain\.com$
RewriteRule ^\/2012\/subdirectory1\/$
"http\:\/\/www\.newdomain\.com\/2012\/subdirectory1\/" [R=301,L]
谢谢!
答案 0 :(得分:1)
我认为你只想要一些简单的东西:
RewriteRule ^2012/$ http://www.newdomain.com/blog/ [L,R=301]
RewriteRule ^2012/subdirectory/?$ http://www.newdomain.com/blog/subdirectory/ [L,R=301]
或者也许:
RewriteRule ^2012/(.*)$ http://www.newdomain.com/blog/$1 [L,R=301]
这些规则必须