If a problem occurs on the website or the page accessed by the user does not exist, the Server Returns Error Code 404. The default 404 page of nginx is:
650) this. width = 650; "title =" 2013-09-16_120850.jpg "src =" http://img1.51cto.com/attachment/201309/120914931.jpg "width =" 710 "height =" 101 "alt =" 120914931.jpg"/>
Step for customizing the error page
1. Create a 404 error page and place it in the root directory of the website.
vim 404.htmlwelcome,my name is 404
2. Add the following content to the http {} definition area of the nginx. conf file:
fastcgi_intercept_errors on;
This command is used to determine whether to redirect the client to the 4xx and 5xx error pages,
3. The error_page command is used to specify the error page. You can add
error_page 404 = /404.html;
Test:
650) this. width = 650; "title =" 2013-09-16_133644.jpg "src =" http://img1.51cto.com/attachment/201309/133715692.jpg "alt =" 133715692.jpg"/>
Error_page command syntax:
Error_page 502 503 504/50 x.html; # in case of a 502,503,504 error status code, the error code error_page 403 contains 404 = 200/empty.gif in the/50.html file is displayed. # The Error Code 404 is returned, change the status code to 200 and display the specified file content to the client.
Summary of the custom error page:
Fastcgi_intercept_errorson must be added;
The custom 404 page must be larger than 512 bytes; otherwise, the default 404 page of IE appears.
This article is from the "Lang taosha" blog, please be sure to keep this source http://caisangzi.blog.51cto.com/6387416/1297681