Environment
This environment is Nginx with Wordpress Multisite installed.
Question
I need to redirect the primary multisite domain (e.g. domain.com, www.domain.com) to another domain (e.g. domain-new.com, www.domain-new.com). But I don't want sub-folders to redirect. For example, the /wp-admin/ folders needs to NOT redirect, otherwise I'll be unable to administer the multisite network.
Obviously, I don't want any other domains to redirect. Just the one stated above.
I found instructions on how to do this in Apache, but I haven't been able to figure it out in Nginx.
What I came up with so far
I came across the following:
server {
listen 80;
server_name domain.com www.domain.com;
rewrite ^ $scheme://www.domain-new.com$request_uri permanent;
But this will also redirect sub-folders of domain.com. I was to sure how to make it exclude wp-admin
folder from the redirection.
I also came across this option:
location = / {
rewrite ^ http://domain-new.com/$uri permanent;
}
But I couldn't find anything on whether the location
command can include a domain, and if it can, how to ensure a specific sub-folder (wp-admin
) is not included in the redirect?