404 error page under Nginx configuration

Source: Internet
Author: User

1. Create your own 404.html page and place it in the root directory of your Web site.

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

3. Change the nginx.conf (or separate site profile)
Join in Server zone: Error_page 404/404.html or Error_page 404 http://www.xxx.com/404.html (It is not recommended to use this absolute path, someone will return 200, but my test is yes, Not on both sides =)

4. Test nginx.conf Correctness:/usr/local/nginx/sbin/nginx–t

5. Restart Nginx Effective:/usr/local/nginx/sbin/nginx-s Reload

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

Error_page 502 503 504 =/50x.html;

Precautions:

1. Must be added: Fastcgi_intercept_errors on; If this option is not set, there is no effect even if 404.html is created and Error_page is configured. 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, so that the rankings unfavorable.

3. The custom 404 page must be greater than 512 bytes, otherwise the IE default 404 page may appear. (No validation, please authenticate yourself)

Reference link http://www.jb51.net/article/32213.htm

404 error page under Nginx configuration

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.