3

I have a server with multiple domains pointing to it (it has Wordpress Multisite running on it).

One of those domains (e.g., mydomain.xxx) I need to redirect to another domain, which is on a different server, yet I want to let through request to mydomain.xxx/wp-admin/* on the nginx server in question.

For example...

I want all requests to www.mydomain.xxx/wp-admin/* to be accepted and handled by the Nginx server in question (the one with the rule on it). Also, www.mydomain.xxx/wp-login.php... will need to be accepted. Anything else requested for mydomain.xxx or www.mydomain.xxx should be redirected to https://myotherdomain.xxx.

For example, www.mydomain.xxx and mydomain.xxx and (www).mydomain.xxx/anythingelse (except /wp-admin/* and wp-login.php...) should be redirected.

When the request is redirected, it's not necessary to include in the rewrite anything that might have been put after the domain name. So in the case of mydomain.xxx/folder1/ the /folder1/ portion can be completely ignored.

Currently I have server_name www.mydomain.xxx and server_name mydomain.xxx being listened for, and then I have:

if ($host = www.mydomain.xxx) {
    rewrite ^/$ https://www.myotherdomain.xxx permanent;
}

But obviously that doesn't allow www.mydomain.xxx/wp-admin/ to get through.

Also, requests for www.mydomain.xxx/wp-login.php?... will need to get through too.

What's the best way to achieve this?

  • I'm curious if this question is asking the impossible, or hasn't been explained clearly enough? I see it's been voted up three times, and yet no responses. – inspirednz May 17 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.