Nginx 404 50x Configuration (reprint)

Source: Internet
Author: User

(reproduced) http://www.cnblogs.com/jiangyao/archive/2010/07/10/1774981.html

1.Create your own 404.html page

2.Change nginx.conf in the HTTP definition area:fastcgi_intercept_errors on;

3.Change nginx.conf (or separate site profile, for example, in NginxSitesSite configuration file under-enabled)

In the server zone join:error_page 404/404.htmlorerror_page 404 =http://www.xxx.com/404.html

4.Restart nginx after change, test nginx.conf correctness:/opt/nginx/sbin/nginx–t

errors such as #502 can be configured in the same way.

Error_page 502 503 504/50x.html;


Precautions :

1. You must add: fastcgi_intercept_errors on; If this option is not set, even if 404.html is created and Error_page is configured, there is no effect. Fastcgi_intercept_errors syntax: fastcgi_intercept_errors on|off default: fastcgi_intercept_errors off Add Location: http, server, Location by default, Nginx does not support custom 404 error pages, and only this instruction is set to On,nginx to support 404 error redirection. It is important to note that it is not said that setting the Fastcgi_intercept_errors On,nginx will redirect the 404 error. In Nginx, 404 error redirection takes effect if fastcgi_intercept_errors on is set and the Error_page option is set correctly (including syntax and corresponding 404 pages)

2. Do not for the sake of convenience or improve the purpose of home page weight to designate the homepage as 404 error page, do not use other methods to jump to the homepage.

3. The custom 404 page must be greater than 512 bytes, otherwise the IE default 404 page may appear. For example, suppose you have customized 404.html with a size of only 11 bytes (content: 404 error).

Nginx 404 50x Configuration (reprint)

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.