别离应用 alias 和 root 配置拜访 b.html

1.1 root->url追加到root后定位

nginx中的root配置:

location ^~ /app1/ {    root /web;}# 拜访: localhost/app1/b.html
b.html 在服务器的目录: /web/app1/b.html
  1. 拜访时url是什么?

    localhost/app1/b.html
  2. 拜访url映射到哪里?

    /app1/b.html:

    root+location 映射: /web/app1/b.html

1.2 alias->url被alias替换

nginx中的alias配置:

location ^~ /app2/ {    alias /web;}b.html目录: /web/b.html拜访: localhost/app2/b.html论断: 相当于替换
b.html 在服务器的目录: /web/b.html
  1. 拜访时url是什么?

    localhost/app2/b.html (url和下面相似)
  2. 拜访url映射到哪里?

    /app2/b.html:

    alias替换location 映射: /web/b.html

1.3 小结

alias:location的uri会被alias的替换;

root:location的uri会追加到root的前面连起来;