nginx中root和alias区别

nginx中root和alias区别


location /www/ {
    alias html/www/;
}

location /www/ {
    root html/www/;
}   

在本例中:

  • 使用alias,则不需要在目录html/www/下再建立一个wwww目录
  • 使用alias,必需要加/,不然后报错: /usr/local/nginx/html/wwwindex.html" failed (2: No such file or directory)
  • 使用root,需要在目录html/wwww/下再建立一个wwww目录,不然会报错: open() "/usr/local/nginx/html/www/www/index.html" failed (2: No such file or directory)

猜你喜欢

转载自blog.csdn.net/u013887008/article/details/83790809