1.创建自己的404.html页面。
2.更改nginx.conf在超文本传送协议(超文本传输协议的缩写)定义区域加入:fastcgi _ intercept _ errors on
3.更改nginx.conf或虚拟主机的域名。服务器区添加conf:error _ page 404/404 . html;
4.测试nginx.conf正确性:/usr/local/nginx/sbin/nginx -t
If it is correct, the following information should be displayed: configuration file /opt/nginx/conf/nginx.conf Syntax is normal. Configuration file /opt/nginx/conf/nginx.conf has been tested successfully.
5.重启nginx/usr/local/nginx/sbin/nginx-s重新加载
备注:1。您必须添加:fastcgi _ intercept _ errors on如果未设置此选项,即使创建了404.html并配置了error_page,也不会有任何效果。
2.不要为了省事或者提高首页权重而将首页指定为404错误页,也不要通过其他方法跳转到首页。3.自定义的404页面必须大于512字节,否则可能会出现IE默认的404页面。举个例子,
假设404.html是定制的,大小只有11字节(内容:404错误)。