nginx部署vue刷新404

解决项目部署到nginx服务器中刷新页面404的问题

编辑配置文件nginx.conf
vi nginx.conf

输入命令 i 进入编辑模式,在指定位置添加代码: try_files $uri

 

$uri/ /index.html;
location / {
root ...
index ...
try_files $uri $uri/ /index.html; ---解决页面刷新404问题
}


$uri/ /index.html;
location ^~/wevue {
root ...
index ...
try_files $uri $uri/ /wevue/index.html; ---解决页面刷新404问题
}

 

posted @ 2023-02-17 08:40  黄橙  阅读(189)  评论(0)    收藏  举报