我想匹配一个特定的位置URL,以在我的网站上提供一个静态文件
这是我要实现的两种行为:
(工作中,但日志中显示错误) http://mywebsite.net 服务 /var/www/html/portfolio/index.html
(不工作) http://mywebsite.net/project 服务 /var/www/html/project/build/index.html >
这是我的实际代码:
server {
listen 80 default_server;
listen [::]:80 default_server;
error_log /home/florian/nginx_www.error.log;
root /var/www/html/portfolio;
index index.html;
location = /project {
root /var/www/html/project/build;
index index.html;
}
}
这是我得到的实际错误:
2019/01/19 20:38:47 [error] 7780#7780: *4 open()
"/var/www/html/project/build/project" failed (2: No such file or
directory), client: XX.XX.XX.XX, server: , request: "GET /project
HTTP/1.1", host: "mywebsite.xx.net"
此行为实际上是正常的,因为此URL不能提供任何正确的信息。 我希望该网址可以投放:
此外,当我使用此URL http://mywebsite.net访问我的网站时,我也遇到了问题。但是文件仍在提供中
2019/01/19 20:37:46 [error] 7780#7780: *5 open()
"/var/www/html/portfolio/undefined" failed (2: No such file or
directory), client: XX.XX.XX.XX, server: , request: "GET /undefined
HTTP/1.1", host: "mywebsite.xx.net", referrer:
"http://mywebsite.xx.net/"