nginx配置静态页面访问,从index.html页面点击其他页面访问失败

nginx配置静态页面访问,已经配置好了,输入ip 默认访问的是我的 index.html,但是还有其他html页面,从index.html页面访问其他页面 404,写的是相对路径,为什么访问不了,需要怎么设置
listen 80;

    server_name  localhost;
root   html/project;
index  html/index.html index.htm;

文件目录如下:
clipboard.png

clipboard.png
已经映射到index.html中了 css效果也可以正确渲染,但是点击index.html页面中的a链接访问about.html访问失败

clipboard.png
求解应该怎么设置呢?

阅读 9k
3 个回答

index 写的不对,你该成index index.html index.htm;然后再看看效果。

但是这样你会发现你的资源文件又无法访问了,这是因为你的 root 没有设置对

root html/project/html;

改成下面这样

root   html/project;

location ~ (.+)\.html${
   root   html/project/html;  
}

不知道为什么,得把html文件夹下的文件全放到项目根目录下,这样就可以了,
但是css文件引用的时候是 ../css 这样不都出去项目根目录了 搞不懂

推荐问题