Nginx: content gradation root & alias
Module ngx_http_core_module (nginx.org)
root & alias 都属于ngx_http_core_module模块
root的处理结果是:root路径+$request_uri
alias的处理结果是:alias路径 + ($request_uri - location中写的路径)
*** / 有无 *** root * alias的处理不同
root 是附加$request_uri到 root 指定的路径, 因为$request_uri肯定以 / 开头, 所以root如果以 / 结尾, 则 / 会重复, Nginx会自动压缩 /, 即使不压缩, 到文件系统寻找文件也没有问题
alias 是把location写出的路径去掉, 因此alias指定的路径最有有无 / , 和location指定的路径最有有无 / 要匹配
实验:
编译选项:
--prefix=/usr/share/nginx --with-debug
root:
alias:
$uri 即访问路径是否以 / 结尾: