1. Modify nginx.conf HTTP
Add fastcgi_intercept_errors on to nginx.conf file HTTP field;
http {
.......
fastcgi_intercept_errors on;
2. Configure the conf server
Configuration error_page 404
server { listen 80; server_name www.zhangguoye.com; index index.html index.htm; root /home/wwwroot; error_page 404 /404.html; location = /404.html { root /home/wwwroot/; # Add custom 404.html} to this directory
3. Restart nginx
Restart NGINX with Restart or Reload for the configuration to take effect.