咨询热线:4006-75-4006
售前:9:00-23:30 备案:9:00-18:00 技术:7*24h
nginx 作为web服务器,如果没有自定义过404设置,一般一个“404 Not Found”的页面提示,作为网站访问,自然希望即使是报错页面也要做的美观一点。
1.开启nginx自定义设置,需要先在ngnix.conf 文件中添加 fastcgi_intercept_errors on;
nginx.conf 文件http 区域添加
http { ....... fastcgi_intercept_errors on;
2. 在对应的虚拟主机配置文件中定义404文件路径,直接在server 区域中增加,当然对于的404.html文件要放到站点根目录下
server { listen 80; server_name www.landui.com ; access_log /home/susecui.cn.log combined; index index.html index.htm index.php; root /home/susecui; error_page 404 /404.html;
我自己测试出来的error_page 404 不能加等号,有的教程提示为error_page 404 = /404.html;
3.重启一下nginx 访问测试
service nginx restart