我在nginx内设置这个别名很麻烦,正确显示我的网站.
我关心的网站应该可以从mywebsite.com/mr访问,并且不同于位于mywebsite.com/的网站.该网站位于/ fullpath(简化简称)网站需要提供三种内容:
>位于/fullpath/index.html的索引文件.
>其他html文件(浏览器中不显示.html扩展名).
>静态资源(js / css / img)位于/ fullpath和子目录中.
我尝试改变了try_files中匹配的顺序,发现它们都工作的情况,而不是在同一时间:
location /mr {
default_type "text/html";
alias /fullpath;
# with this one 1 and 3 work
# try_files $uri/index.html $uri.html $uri;
# with this one 2 and 3 work
# try_files $uri $uri.html $uri/index.html;
# with this one 1 and 2 work
try_files $uri.html $uri/index.html $uri;
}
当一个人不工作404的.有人知道我能如何正确地提供各种文件?
显然是别名和try_files don’t work together.但是,我不认为你需要使用别名.
location /mr {
default_type "text/html";
try_files /fullpath/$uri /fullpath/$uri.html /fullpath/$uri/index.html /fullpath/index.html;
}
哪个会尝试:
>精确文件.
>添加了.html的文件.
>路径中的索引.
>默认索引.
我认为根指令使用try文件,但无法测试.
server{
location /mr {
root /home/mysite/fullpath;
default_type "text/html";
try_files $uri $uri.html $uri/index.html index.html;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。