Lnmp 404 Configuration
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, centoscn.com, Edit
Vi www.centoscn.com. conf # modify the yellow part as needed
3. Specify the 404 error page
1) The current website root directory (for example,/home/wwwroot/centoscn.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 the following error_page 500/500 .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.