Nginx中进行简单的if-else判断
location /aaa/ {
proxy_pass http://localhost:8080/aaa/;
# 因为Nginx中只支持简单的if语句,所以用以下方式模拟and条件
set $flag "";
if ($query_string ~ ".*(?:^|\?|&)redirect=healthClaim(?:(?:&.*)|$)") {
set $flag "${flag}1";
}
if ($query_string ~ ".*(?:^|\?|&)redirect=healthClaim(?:(?:&.*)|$)") {
set $flag "${flag}1";
}
if ($flag ~* "11") {
# 这里写redirect不为url1和url2的代码
rewrite ^/aaa/user/index(.*) /bbb/ last; # 主页
rewrite ^/aaa/user/login(.*) /bbb/ last; # 登陆
}
}