nginx同一server配置多个前端工程location访问404问题

1:问题描述
在同一server块中,除了默认的location块外,配置一个前端工程,访问前端页面404,配置如下:

location / {
     root   html;
     index  index.html index.html;
}
location /book {
     root   html/book;
     index  index.html index.html;
}

2:解决方案
location中如果一个特定的url要使用别名,不能用root,alias指定的目录是准确的,root是指定目录的上级目录,改成如下即可

location /book {
         alias   html/book;
         index  index.html index.html;
}

猜你喜欢

转载自blog.csdn.net/chenlixiao007/article/details/105548248