码迷,mamicode.com
首页 > 其他好文 > 详细

nginx if多条件判断

时间:2020-03-02 12:54:47      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:page   htm   http   listen   bsp   list   多条件   index   file   

server {
    listen 10001;
    server_name  qwe.com asd.com;
    set $flag 0;
    if ($http_user_agent ~* "Chrome"){
        set $flag "${flag}1";
    }
    if ($host ~* qwe.com){
        set $flag "${flag}1";
    }
    if ($flag = "011"){
        rewrite ^.+ http://asd.com:10001/test2;
    }
    
    location ^~ /test1 {
        try_files $uri $uri/ /test1/index.html;
        root   html;
        index  index.html index.htm;
        autoindex off;
    }

    location ^~ /test2 {
        try_files $uri $uri/ /test2/index.html;
        root   html;
        index  index.html index.htm;
        autoindex off;
    }
        
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}


nginx if多条件判断

标签:page   htm   http   listen   bsp   list   多条件   index   file   

原文地址:https://www.cnblogs.com/lazy-sang/p/12394649.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!