赞
踩
alias 的官方说明: http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
Syntax: alias path;
Default: —
Context: location
The path value can contain variables, except $document_root and $realpath_root.
location /i/ {
alias /data/w3/images/;
}
“/i/top.gif”
时, 返回文件“/data/w3/images/top.gif”
。location ~ ^/users/(.+\.(?:gif|jpe?g|png))$ {
alias /data/w3/images/$1;
}
“/user/head.png”
时, 返回文件“/data/w3/images/head.png”
。“/user/2021/04/18/d3n4iik9.png”
时, 返回文件“/data/w3/images/2021/04/18/d3n4iik9.png”
。location /images/ {
alias /data/w3/images/;
}
location /images/ {
root /data/w3;
}
“/images/head.png”
时,且使用 alias
的情况下,返回文件 “/data/w3/images/head.png”
(alias path
+ head.png
)。“/images/head.png”
时,且使用 root
的情况下,返回文件 “/data/w3/images/head.png”
(alias path
+ /images/head.png
)。location
为 /images/
,且 root
目录下包含 images
时,nginx 推荐使用root(上面的例子,nginx推荐使用root)。反之,当 location
为 /images/
,且 root
目录下未包含 images
时,此时使用root将不能正常工作,需要使用 alias。这样写是403错误:
location ~ ^/tt/ {
alias /data/test/;
index index.html index.htm;
}
这样写正确:
location ~ ^/tt/(.*)$ {
alias /data/test/$1;
index index.html index.htm;
}
rw权限
r权限
参考这里:https://blog.csdn.net/u010999809/article/details/100084838
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。