数码资讯
nginx设置404错误页面方法
1.创建自己的404.html页面 2.更改nginx.conf在http定义区域加入: fastcgi_intercept_errors on; 3.更改nginx.conf或虚拟主机的域名.conf在server 区域加入: error_page 404 /404.html; 4.测试nginx
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
1.创建自己的404.html页面
2.更改nginx.conf在http定义区域加入: fastcgi_intercept_errors on;
3.更改nginx.conf或虚拟主机的域名.conf在server 区域加入: error_page 404 /404.html;
4.测试nginx.conf正确性: /usr/local/nginx/sbin/nginx -t
如果正确应该显示如下信息: the configuration file /opt/nginx/conf/nginx.conf syntax is ok configuration file /opt/nginx/conf/nginx.conf test is successful
5.重启nginx /usr/local/nginx/sbin/nginx -s reload
注意事项: 1.必须要添加:fastcgi_intercept_errors on; 如果这个选项没有设置,即使创建了404.html和配置了error_page也没有效果。 2.不要出于省事或者提高首页权重的目的将首页指定为404错误页面,也不要用其它方法跳转到首页。 3.自定义的404页面必须大于512字节,否则可能会出现IE默认的404页面。例如,假设自定义了404.html,大小只有11个字节(内容为:404错误)。
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。