I’m trying to separate out a WordPress site that has 4 specific blog sections built with custom post types to their own individual sites.
I have urls that look like:
example.com/site1/postname
example.com/site2/postname
etc
What I need to do is redirect all the posts under each site out to the new site while leaving the root page where it is.
So example.com/site1/postname becomes example2.com/postname
but example.com/site1/ needs to stay as example.com/site1/
And the same for the other 3 sites. Hope that makes sense.
I have this and it works great at redirecting the posts to the new site but it also redirects the root base as well and can’t work out what to change to fix that.
RewriteEngine on
RewriteRule ^site1/(.*)$ http://www.example2.com/$1 [L,R=301]
To redirect everything except root of all 4 sites use:
.+
after these sites will make sure to not to match root of these folders.