LNMP one-click installation package 404 error page setting tutorial

Source: Internet
Author: User
The default 404 error page is not very friendly to visitors and search engines. it takes some time to set error prompt pages such as 404 on the server to better retain visitors. As the one-click installation package of LNMP. ORG does not provide error messages such as 404 by default, we need to add several lines of code and files by ourselves. LNMP one-key installation package http://www.centoscn.com/CentosSoft/tool/2013/0721/397.html&n

The default 404 error page is not very friendly to visitors and search engines. it takes some time to set error prompt pages such as 404 on the server to better retain visitors. As the one-click installation package of LNMP. ORG does not provide error messages such as 404 by default, we need to add several lines of code and files by ourselves.

LNMP one-key installation package http://www.centoscn.com/CentosSoft/tool/2013/0721/397.html

1. enable 404 page response
1. enter the nginx configuration Directory
cd /usr/local/nginx/conf

2. modify the nginx. conf file
vi nginx.conf

3. add a string
Fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64 k; fastcgi_buffers 4 64 k; limit 128 k; limit 256 k; limit on; # Display error information

Search for the above strings and add the red strings below them. Save and exit after adding.



2. set the 404 error page
1. open the VM configuration file

Enter the vhost Directory


cd /usr/local/nginx/conf/vhost

2. edit related files

For example, kwxonline.com, Edit


Vi www.kwxonline.com. conf # Modify the yellow part as needed

3. specify the 404 error page
1) the root directory of the website (for example,/home/wwwroot/kwxonline.com#404.html and other files.
2) Add:
Error_page 404/404 .html; # of course, if you want to specify the 500 error, you can also add error_page 500/500 .html; # You can also use the following method. for other errors, note that you need to modify the code and file name. Error_page 404 = http://www.centoscn.com/404.html


III. test whether the settings are correct
/usr/local/nginx/sbin/nginx -t

If no problem exists, the system will prompt:


4. load nginx to make it take effect
/usr/local/nginx/sbin/nginx -s reload

 

Supplement:

Before you perform a 404 error jump, you must add fastcgi_intercept_errors on ;. If this parameter is not added, the second step is to perform cloud migration. Nginx does not support custom 404 error pages by default. nginx supports 404 error redirection only when this command is set to on.
Note: The custom 404 page must be larger than 512 bytes; otherwise, the default 404 page of IE or other browsers may appear.

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.