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

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

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 nginx

相关文章
相关标签/搜索