我有一个域example.com
我想要有2个子域名: a.example.com和b.example.com指向/var/www/a和/var/www/b 。
所以我使用这个nginxconfiguration:
server { server_name a.example.com; root /var/www/a; try_files $uri /index.html; } server { server_name b.example.com; root /var/www/b; try_files $uri /index.html; }
它按预期工作。
但是,当我打开c.example.com它呈现/var/www/a/index.html
请注意,我没有为c.example.com指定任何规则。
那为什么它的行为就像是匹配a.example.com ?
当没有其他匹配的时候,nginx会把第一条规则当作默认规则吗? – 即使该规则中的server_name指令与URL不匹配?