admin管理员组文章数量:1122846
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/ --> no redirection
oldone/wp-admin --> no redirection
oldone/wp-login --> no redirection
oldone/about --> newone/about
oldone1/about --> newone1/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 redirect
RewriteCond %{HTTP_HOST} ^oldone$ [NC]
#redirects domain to www.oldone
RewriteRule ^(.*)$ /$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.oldone\$ [NC]
RewriteCond %{REQUEST_URI} !^/(wp-login/?|$)
RewriteCond %{REQUEST_URI} !^/(wp-admin/?|$)
RewriteRule ^(.*)$ /$1 [R=301,L]
####
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]
####
Share
Improve this question
edited Jul 23, 2018 at 11:27
Johansson
15.4k11 gold badges43 silver badges79 bronze badges
asked Jun 6, 2018 at 21:22
unforgivenunforgiven
133 bronze badges
1 Answer
Reset to default 0Try adding something like the following at the top of your .htaccess
file:
RewriteCond %{HTTP_HOST} ^(www\.)?oldone\.com
RewriteCond ${REQUEST_URI} !^/wp-admin
RewriteCond ${REQUEST_URI} !^/wp-login
RewriteRule . http://newone.com%{REQUEST_URI} [R,L]
Make sure the browser cache is clear. Change to 301 (if that is the intention) only when you are sure it's working OK.
Repeat for any other oldoneN.com
/ newoneN.com
combos, unless there is a pattern with the domain names?
Alternatively, if you never want to redirect /wp-admin
or /wp-login
etc for any domain then you could include an exception for these URL-paths. Although that would probably interfere with some of the other MU directives.
本文标签: redirectMultisite Redirection to new domains
版权声明:本文标题:redirect - Multisite Redirection to new domains 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283819a1927091.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论