Ubuntu nginx 配置404错误页面

时间:2023-03-08 21:04:45
Ubuntu nginx 配置404错误页面

1.创建自己的404.html页面;

2.更改nginx.conf在http定义区域加入:

/etc/nginx# vim nginx.conf 下添加 fastcgi_intercept_errors on; 
 http{
......
fastcgi_intercept_errors on;
......
}

3.更改/etc/nginx/sites-enabled/default 文件

 #error_page  /.html;
改为
error_page 404 = /404.html; 或者 error_page 404 = http://www.xxx.com/404.html

4.测试nginx.conf正确性: nginx –t

5.重启nginx: nginx -s reload