例如,我想要这样做:
if ($http_user_agent ~ "MSIE 6.0" || $http_user_agent ~ "MSIE 7.0" (etc,etc)) { rewrite ^ ${ROOT_ROOT}ancient/ last; break; }
而不是这个:
if ($http_user_agent ~ "MSIE 6.0") { rewrite ^ ${ROOT_ROOT}ancient/ last; break; } if ($http_user_agent ~ "MSIE 7.0") { rewrite ^ ${ROOT_ROOT}ancient/ last; break; }
Nginx拒绝这个语法(减去(etc等)),我没有看到关于这个文档的任何东西。 提前致谢。
另外,我们select不使用$ ancient_browser指令,所以这不是一个选项。
在Ubuntu 12.04上设置Nginx的iRedMailpipe理站点
Nginx:缓冲链
从子文件夹服务Express.JS应用程序
Nginx,fastcgi和open socket
Docker 1.9卷在Mac OS上不能更新。 图片Nginx
厨师独奏错误Errno :: ENOENT:没有这样的文件或目录 – solo.rb
msg:ConnectionError(ProtocolError('Connection aborted。',error(2,'No such file or directory')),)
C中好奇的string复制函数
编辑:
由于阿列克谢十没有添加新的答案,我会编辑我的这个情况下给他更好的答案。
if ($http_user_agent ~ "MSIE [67].")
原始答案:
Nginx不允许多个或嵌套的if语句,但是你可以这样做:
set $test 0; if ($http_user_agent ~ "MSIE 6.0") { set $test 1; } if ($http_user_agent ~ "MSIE 7.0") { set $test 1; } if ($test = 1) { rewrite ^ ${ROOT_ROOT}ancient/ last; }
它并不短,但它允许你做检查,并把重写规则只有一次。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。