NGINX 配置404错误页面

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.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

6、502 等错误可以用同样的方法来配置。  

error_page  500 502 503 504  /50x.html; 

Nginx 404 (1)

Nginx 404 (2)

评论已关闭。