将WP站点上的整个目录重定向到新域,并带有一些子目录例外

I am trying to redirect an entire directory on a WP site to a directory on a new domain, with a few subdirectory exceptions that exist on the new domain.

e.g.

Redirect /2012/ to newdomain.com/blog
Redirect /2012/subdirectory to newdomain.com/2012/subdirectory

This is what I have that is not working:

#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]

Thanks!

I think you just want something simple:

RewriteRule ^2012/$ http://www.newdomain.com/blog/ [L,R=301]
RewriteRule ^2012/subdirectory/?$ http://www.newdomain.com/blog/subdirectory/ [L,R=301]

Or maybe:

RewriteRule ^2012/(.*)$ http://www.newdomain.com/blog/$1 [L,R=301]

These rules need to be before any wordpress rules in your htaccess file.