[英]Nginx redirect if not host and if not request uri
Can anyone see why the following Nginx if statements doesn't work 谁能看到以下Nginx if语句为什么不起作用的原因
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 用英语来说,如果主机不是subdomain.mydomain.com,并且请求URI不是/.well-known/acme-challenge/*,那么我希望它重定向到另一个域
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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.