Configure custom 404 error page Steering in Nginx environment to avoid displaying blunt, unfriendly error messages to users. You can give the following hint: Sorry, the page you visited does not exist or has been deleted.
Precautions:
① first create a 404 error when the page appears, such as placed in the root directory of your site 404.html. (Free content)
② Add fastcgi_intercept_errors on to the HTTP zone in nginx.conf:
HTTP {
...
Fastcgi_intercept_errors on; #支持自定义4xx, 5xx pages
...
}
③ in the server area of nginx.conf (if the Web site has a separate profile, you need to include it in the server area of its configuration file) to add Error_page 404:
Situation one: The Global 404 page Jumps
Server
{
...
Error_page 404 = 404.html; #全局跳转
or error_page 404 = http://www.xxx.com/xxx/404.html; # the difference between the absolute path and the relative path.
}
Scenario Two: 404 page jump For one of the paths of the server
location/news/{#只会在访问此路径时才会跳转
alias/happyface/hf_channel/;
Error_page 404 = 404.html; #此时404. html placed under/happyface/hf_channel/
}
Note: The status code returned at this time is 200, if you want to return a status code of 404, then "=" should be removed.
If you want to customize other errors, similarly:error_page 502 503 504 =/50x.html;
④ restart Nginx after saving.
/happyface/tengine/sbin/nginx-c Conf/nginx.conf-s Reload
This article is from the "Nobody Knows" blog, please be sure to keep this source http://cuixuemei.blog.51cto.com/8852728/1683006
Nginx Custom 404 Error page