发布到服务器后可以正常访问,但是刷新当前页面不行,报404错误
解决办法:修改nginx配置
修改前:
server {
listen 80;
server_name xxx.xxx.com;
location / {
root /var/www/build;
index index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /var/www/html;
}
}
修改后:
server {
listen 80;
server_name xxx.xxx.com;
location / {
root /var/www/build;
try_files $uri /index.html
}
error_page 404 /404.html;
location = /404.html {
root /var/www/html;
}
}

本文介绍了一种常见的Nginx配置问题,即在服务器上部署应用后,刷新页面出现404错误的解决方案。通过调整Nginx配置文件中的location指令和try_files参数,可以有效解决该问题。
1305

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



