Can anyone see why the following Nginx if statements doesn't work
if ($host != subdomain.mydomain.com) {
set $test A;
}
if ($request_uri != /.well-known/acme-challenge/(.*?)) {
set $test "${test}B";
}
if ($test = AB) {
rewrite ^/(.*) https://www.anotherdomain/$1 permanent;
break
}
In English, if the host is not subdomain.mydomain.com and the request URI is not /.well-known/acme-challenge/* then I want it to redirect to another domain
The following code in the end worked for me
if ($host != subdomain.mydomain.com) {
set $test A;
}
if ($request_uri !~ /\.well-known) {
set $test "${test}B";
}
if ($test = AB) {
rewrite ^/(.*) https://www.anotherdomain/$1 permanent;
break
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.