nginx root alias try-files 用法
location /vuestudy {rootD:/webapps;#indexindex.html index.htm;try_files $uri $uri/ /vuestudy/default.html;}比如 请求 127.0.0.1/vuestudy 会依次查找1.文件d:/webapps/vuestudy/index.html2.文件夹 d:/webapps/vuestudy/ind
location /vuestudy {
root D:/webapps;
try_files $uri $uri/ /vuestudy/default.html;
}
比如 请求 127.0.0.1/vuestudy 会依次查找
1.文件d:/webapps/vuestudy/index.html
2.文件夹 d:/webapps/vuestudy/index.html文件夹下的index.html
3.请求127.0.0.1/vuestudy/default.html
如果 d:/webapps/vuestudy/default.html也没有的话,会报500错误。原因是无限循环。
location /vue {
alias D:/webapps/vuestudy;
index index.html index.htm;
try_files $uri $uri/ /vuestudy/default.html;
}
而 alias 正如其名,alias指定的路径是location的别名,不管location的值怎么写,资源的 真实路径都是 alias 指定的路径。
比如 请求 127.0.0.1/vue 会依次查找
1.文件d:/webapps/vuestudy/index.html
2.文件夹 d:/webapps/vuestudy/index.html文件夹下的index.html
3.请求127.0.0.1/vuestudy/default.html
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)