I want to redirect requests on two conditions using nginx.
This doesn\'t work:
if ($host = \'domain.com\' || $host = \'domain2.com\'){
rewrite ^/(
Rewriting multiple domains to a single domain and avoiding a looping condition in the browser.
server {
listen 80;
server_name www.wanted_domain.com wanted_domain.com www.un_wanted_domain.com un_wanted_domain.com;
if ($host = 'un_wanted_domain.com'){
return 301 $scheme://www.wanted_domain.com$request_uri;
}
if ($host = 'www.un_wanted_domain.com'){
return 301 $scheme://www.wanted_domain.com$request_uri;
}