首页 > Web开发 > 详细

Nginx笔记:对url中携带的参数进行多次判断

时间:2018-01-18 14:39:21      阅读:325      评论:0      收藏:0      [点我收藏+]

Nginx中只支持简单的if语句,不支持多条件判断和嵌套,通过特殊的方式也可以达到效果

location / {
                proxy_set_header        Host $host;
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                set $res 0;
                if ($arg_width ~ \d+){
                    set $res "${res}1";
                }
                if ($arg_height ~ \d+){
                    set $res "${res}1";
                }
                if ($res = "011"){
                    proxy_pass              http://pe.cut;
                    access_log              /dev/null;
                }
                #if ($res != "011"){
        #    return http://xxx.xxx.xxx;    
                #}
    }

 

Nginx笔记:对url中携带的参数进行多次判断

原文:https://www.cnblogs.com/djoker/p/8310024.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!