美文网首页
Nginx的root和alias

Nginx的root和alias

作者: 喵吉呀呀 | 来源:发表于2019-03-08 15:51 被阅读0次

root:

location /path {
root /uri
}

结果:/uri/path
eg:/path/test.jpg -> uri/path/test.jpg

· location的path后面带不带/,对uri的影响不大
· uri必须是path目录下真实存在的目录

alias:

location /path {
alias /uri
}

结果:/uri
eg:/path/test.jpg -> uri/test.jpg

· location的path后面不带/,对uri的影响不大
· location的path后面带/,uri也必须带/
· 优势是可以不使用目录名

推荐写法:
· 在location /中配置root目录;
· 在location /path中配置alias虚拟目录。

相关文章

网友评论

      本文标题:Nginx的root和alias

      本文链接:https://www.haomeiwen.com/subject/epwrpqtx.html