与不同的根文件夹中的多个位置,我希望成为一个子域的子域和目录的根URL到我的服务器上的两个不同的文件夹。下面是简单的设置,我有和没有工作...nginx的配置与子域
server {
index index.html index.htm;
server_name test.example.com;
location/{
root /web/test.example.com/www;
}
location /static {
root /web/test.example.com/static;
}
}
在这个例子中去test.example.com/会带来/web/test.example.com/索引文件WWW
,并打算test.example.com/static将使索引文件中/web/test.example.com/static
他不需要'别名'。请阅读[官方文档](http://nginx.org/r/alias),而不是用户填写的社区wiki。 Quote:*当位置匹配指令值的最后部分时,最好使用root指令*。 – VBart 2012-07-20 16:20:40
这为我工作,除了它缺少一个尾部斜线。别名应为: alias /web/test.example.com/static/; – ajma 2014-02-27 05:29:13
@VBart这些文档确切地说了你引用他们的话,但是他们根本没有证明这个说法是正确的 - 这看起来像是一种任意的风格选择。你看到它背后的逻辑理由吗? – 2015-05-14 09:21:35