Nginx 中 root 和 alias 的使用区别

1、alias 配置:

location /resources/image/ {
    alias /local_path/image/;
}

# 访问:http://127.0.0.1/resources/image/test.png
# 定位资源路径为:/local_path/image/test.png

 2、root 配置:

location /resources/image/ {
    root /local_path/image/;
}

# 访问:http://127.0.0.1/resources/image/test.png # 定位资源路径为:/local_path/image/resources/image/test.png

如上,alias 会把 location 的值替换掉,而 root 会拼接上 location 的值。

 

posted @ 2020-03-13 17:04  d0usr  阅读(230)  评论(0编辑  收藏  举报