Nginx的alias的用法及与root的区别

出自:https://blog.csdn.net/kinginblue/article/details/50748683

Nginx的alias的用法及与root的区别
http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
http://nginx.org/en/docs/http/ngx_http_core_module.html#root

以前只知道Nginx的location块中的root用法,用起来总是感觉满足不了自己的一些想法。然后终于发现了alias这个东西。

先看toot的用法
location /request_path/image/ {
    root /local_path/image/;
}
这样配置的结果就是当客户端请求 /request_path/image/cat.png 的时候,
Nginx把请求映射为/local_path/image/request_path/image/cat.png

再看alias的用法
location /request_path/image/ {
    alias /local_path/image/;
}
这时候,当客户端请求 /request_path/image/cat.png 的时候,
Nginx把请求映射为/local_path/image/cat.png

posted @ 2018-12-08 12:48  路途寻码人  阅读(347)  评论(0编辑  收藏  举报