1.root的用法
location /request_path/image/ {
root /local_path/image/;
}
这样配置的结果就是当客户端请求 /request_path/image/cat.png 的时候,
Nginx把请求映射为/local_path/image/request_path/image/cat.png
2.alias用法
location /index/ {
alias /usr/share/nginx/html/validation/;
index Ooqw3bcu9r.txt;
}
请求映射结果案例:
请求: -> 映射文件
/index/xxx2.txt->/usr/share/nginx/html/validation/xxx2.txt/index/Ooqw3bcu9r.txt->/usr/share/nginx/html/validation/Ooqw3bcu9r.txt-
/index->/usr/share/nginx/html/validation/Ooqw3bcu9r.txt这是由于配置了index Ooqw3bcu9r.txt;,所以有这个映射
注意:alias中的路径最后必须跟上【/ 】,root的路径最后可跟可不跟,alias支持【正则表达式】路径root不支持
使用 alias映射具体某个文件配置参考
location /itemDetail/oDKuHHCof5.txt {
alias /usr/share/nginx/html/validation/oDKuHHCof5.txt;
index oDKuHHCof5.txt;
}
提示:映射具体文件一般用作文件校验
https://www.syntaxspace.com/article/171.html
评论