How does Nginx set the 404 page?

Source: Internet
Author: User

Common articles on the Internet are added to the server section in the nginx virtual host configuration file:

The code is as follows: Copy code

Error_page 404 =/404.html;

This is not the case. I will find it and find the method.

The code is as follows: Copy code

Fastcgi_intercept_errors on;

Change nginx. conf (or a separate website configuration file, for example, the site configuration file under nginx-> sites-enabled)

In the server area Add: error_page 404 =/404.html or error_page 404 = http://www.xxxx.xxx/404.htm

After reload is complete, the/etc/init. d/nginx reload will be OK, so that the error 404 page will appear normally.

You must add: fastcgi_intercept_errors on. If this token is not set, neither 404.html nor error_page is created.

Effective. Fastcgi_intercept_errors syntax: fastcgi_intercept_errors on | off default: fastcgi_intercept_errors

Off: http, server, and location. By default, nginx does not support custom 404 error pages. Only this command is set to on,

Nginx supports 404 error redirection. Note that if fastcgi_intercept_errors on is set, nginx will set the 404

Error redirection. In nginx, the 404 error redirection takes effect only when fastcgi_intercept_errors on is set and

Error_page option (including syntax and corresponding 404 page)

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.