标签:index log default error html 404 刷新 页面
1.问题:
vue项目部署完成之后,突然发现除了首页,访问其它页面的时候刷新会出现404的问题,如果nginx这块没有配置好的话,便会出现这个问题。好了,现在说下解决方案,顺便也是给自己做个小的笔记。
2.解决:
在nginx配置里添加添加对应的跳转设置。
找到/www/server/panel/vhost/nginx/*.conf;
添加
location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.html =404; }
加#注释掉
index index.php index.html index.htm default.php default.htm default.html;
配置如下
server { listen 80 default_server; server_name zhai.hui.com; # index index.php index.html index.htm default.php default.htm default.html; root /www/wwwroot/zhai.hui.com; #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 #error_page 404/404.html; #SSL-END #ERROR-PAGE-START 错误页配置,可以注释、删除或修改 #error_page 404 /404.html; #error_page 502 /502.html; #ERROR-PAGE-END #PHP-INFO-START PHP引用配置,可以注释或修改 include enable-php-74.conf; #PHP-INFO-END #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效 include /www/server/panel/vhost/rewrite/zhaiquan.huitongqingsuan.com.conf; #REWRITE-END #禁止访问的文件或目录 location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) { return 404; } #一键申请SSL证书验证目录相关设置 location ~ \.well-known{ allow all; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; error_log /dev/null; access_log /dev/null; } location ~ .*\.(js|css)?$ { expires 12h; error_log /dev/null; access_log /dev/null; } location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.html =404; } access_log /www/wwwlogs/zhai.hui.com.log; error_log /www/wwwlogs/zhai.hui.com.error.log; }
标签:index,log,default,error,html,404,刷新,页面 来源: https://www.cnblogs.com/yechangzhong-826217795/p/15353942.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。