[nginx] location 嵌套,以及匹配规则问题。

2018-09-18 14:41:56 +08:00
 wly19960911

location "/server/" is outside location ".*\.(html)"

报错如上。

     location ~.*\.(html) {

            
            location  /server/ {
                add_header Cache-Control no-store,must-revalidate;
                add_header test test1;
            }
            location  /client/ {
                add_header Cache-Control no-store,must-revalidate;
                add_header test test2;
            }
        }

报错的话解释很明确了,但是有个奇怪的情况是,如果我换成了 location ~ /client/ 的话,也就是加了 ' ~ '就不会报错了,求问为什么这两种方式会出现这个差异。

7826 次点击
所在节点    问与答
2 条回复
SakuraKuma
2018-09-18 16:36:17 +08:00
~ 是正则
wly19960911
2018-09-18 16:46:57 +08:00
@SakuraKuma 看来是被网上的教程误解了,到时候我翻翻官方文档看看,最近都没啥时间。感谢回答。

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

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

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

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

© 2021 V2EX