Nginx How to set the custom 404 page

Source: Internet
Author: User

404 errors are errors that are prone to the WWW site access. The most common error hint: 404 Not FOUND. 404 error page settings on the site SEO has a great impact, and improper settings, such as direct to jump home, etc., will be the search engine down the right to pull hair. 404 The purpose of the page should be to tell the user: the page you requested is not there, and also guide the user to browse the site other pages instead of closing the window to leave. The search engine uses the HTTP status code to identify the state of the page. When the search engine gets a bad link, the site should return a 404 status code that tells the search engine to discard the index of the link. If a 200 or 302 status code is returned, the search engine will index the link, resulting in a number of different links pointing to the same page content. As a result, search engines have significantly reduced trust in websites.

Here is the LNMP setting nginx 404 error page Tutorial:

1, vi/usr/local/nginx/conf/nginx.conf edit nginx configuration file, add the following code in the HTTP section:

Fastcgi_intercept_errors on;

650) this.width=650; "alt=" 1.jpg "src=" http://www.sjyhome.com/uploadfile/2013/1005/20131005013348212.jpg "style=" margin:0px;padding:0px; "/>

2, edit the website configuration file, such as this site: vi/usr/local/nginx/conf/vhost/onelone.com.conf, add the following code in the server section:

Error_page 404 =/404.html;

Note: A netizen testing the uplink code needs to remove the equal sign to return the correct 404 state, so please test whether you want to remove the equal sign.

650) this.width=650; "alt=" 2.jpg "src=" http://www.sjyhome.com/uploadfile/2013/1005/20131005013348918.jpg "style=" Margin:0px;padding:0px;border:none; "/>

3, test the configuration file is correct:/usr/local/nginx/sbin/nginx-t, return the following code through:

The configuration file/usr/local/nginx/conf/nginx.conf syntax is okconfiguration file/usr/local/nginx/conf/ Nginx.conf Test is successful

4, restart LNMP effective:/root/lnmp restart.

650) this.width=650; "alt=" 3.jpg "src=" http://www.sjyhome.com/uploadfile/2013/1005/20131005013348949.jpg "style=" Margin:0px;padding:0px;border:none; "/>

5, 404 error page Production considerations:

    1. Do not turn 404 errors to the website homepage, which may cause the homepage to be lowered or disappeared in the search engine

    2. Do not use absolute URLs, if the status code returned using an absolute URL is 302+200, this results in a large number of duplicate pages.

    3. 404 Page Setup is complete, be sure to check that it is correct. The HTTP header information returned must be 404 states. This can be checked by the Server Head Information check tool.

    4. 404 page do not automatically jump, let the user to determine the whereabouts.

    5. The custom 404 page must be greater than 512 bytes, otherwise the IE default 404 page may appear.

Welcome reprint, but please keep the original address http://www.sjyhome.com/nginx/nx-404.html


Nginx How to set the custom 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.