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