第一步:自定义错误页面需先准备好错误图片(这里定义error.jgp图片)
第二步:修改主配置文件:
[root@localhost html]# ls
40x.html 50x.html error.jpg index.html linux.jpg trror.txt
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
添加如下命令,这是一个自定义的404 401 403 408错误页面且
error_page 403 404 401 408 /40x.html; //一旦页面报404 401 403 408错误让他去寻找40x.html
location = /40x.html { //location匹配40x.html找html
root html;
}
结果如图所示: