他们都是 nginx 虚拟目录配置,不同的是他们处理路径的方式。
Defines a replacement for the specified location.
location 部分会替换 path,所以 final path = alias
Sets the root directory for requests. A path to the file is constructed by merely adding a URI to the value of the root directive. If a URI has to be modified, the alias directive should be used.
location 部分会添加到 path 上,所以 final path = root + location
location /img/ {
alias /var/www/image/;
}
# 访问/img/目录里面的文件时,ningx会自动去/var/www/image/目录找文件
location /img/ {
root /var/www/image;
}
# 访问/img/目录下的文件时,nginx会去/var/www/image/img/目录下找文件。]