location / {
root /usr/share/nginx/html/;
index index.html index.htm;
try_files $uri $uri/ @router;
index index.html;
}
location @router {
rewrite ^.*$ /index.html last;
}
Nginx部署Vue项目刷新404问题
最新推荐文章于 2025-10-09 18:02:36 发布
该博客主要探讨了Nginx服务器配置文件的结构,详细解释了`location`指令的用法,包括根目录设置、默认索引文件指定、尝试文件处理以及内部重定向。文章还特别关注了前端路由的实现,通过`@router`别名实现了URL到`index.html`的重写,确保单页应用的正确运行。
971

被折叠的 条评论
为什么被折叠?



