Nginx custom error page

Source: Internet
Author: User
Tags error status code

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.