Multisite Redirection to new domains
I have a multisite website with 5 domains in WordPress which uses WordPress MU Domain Mapping plugin.
I want to redirect every subpage to new domain, but we will be still using the homepage, because it contains some links inside of it, so root, wp-admin
and wp-login
, should be still accessible and not redirected. How to set this up in .htaccess
so WordPress will still function?
example of a domain:
oldone.com/ -- no redirection
oldone.com/wp-admin -- no redirection
oldone.com/wp-login -- no redirection
oldone.com/about -- newone.com/about
oldone1.com/about -- newone1.com/about
... etc ...
.htaccess
:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
### oldone.com redirect
RewriteCond %{HTTP_HOST} ^oldone.com$ [NC]
#redirects domain.com to www.oldone.com
RewriteRule ^(.*)$ http://oldone.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.oldone.com\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/(wp-login/?|$)
RewriteCond %{REQUEST_URI} !^/(wp-admin/?|$)
RewriteRule ^(.*)$ http://newone.com/$1 [R=301,L]
####