location / {
root html/dist;
index index.html index.htm;
#vue的history刷新不404
try_files $uri $uri/ /index.html;
}
在conf文件的nginx.conf里加上注释下面的那句话
在nginx配置文件中,通过`location`块设置路由,确保在Vue应用使用history模式时,刷新页面不会出现404错误。关键配置是`try_files$uri$uri//index.html;`,这将重定向所有未找到的路径到根目录的index.html,从而避免路由失效。
location / {
root html/dist;
index index.html index.htm;
#vue的history刷新不404
try_files $uri $uri/ /index.html;
}
在conf文件的nginx.conf里加上注释下面的那句话
2611
4851
504

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