请教一下,为什么 nginx 的 try_files 在使用 if 过后无效?

2019-04-01 09:36:31 +08:00
 zhaoyc2018
location ~ "/test-p15990\.html$" {
if ( $whitelist = 0 ) {
set $test 1;
}

default_type "text/html; charset=UTF-8";

add_header debug "test1";

try_files /html/p15/990 =404;
}

注销第 2 和第 4 行就正常返回页面,说明设置变量没有问题,如果$whitelist 为 1 时是正常的。

但问题是当$whitelist 为 0 时就不行了呢?
2867 次点击
所在节点    NGINX
5 条回复
uncat
2019-04-01 09:48:56 +08:00
优先级问题,后者高
zhaoyc2018
2019-04-01 09:58:24 +08:00
优先级?没搞懂 @uncat
mcfog
2019-04-01 11:10:35 +08:00
no1xsyzy
2019-04-01 11:29:09 +08:00
我猜应该是 try_files 没有被 if 配置块继承。
zhaoyc2018
2019-04-01 13:22:59 +08:00
add_header 也没有用,看来就是 @mcfog 所说的问题。。。

谢谢各位

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/550696

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX