|
|
Posted on 10/26/2014 11:18:24 AM
|
|
|

Why customize a 404 page
When encountering a 404 error page like the one above, I think 99% of users (unsurveyed, estimated data) will close the page and users will quietly lose. If there is a beautiful page that can guide the user to where he wants to go, it will definitely retain the user. Therefore, every website should customize its own 404 page.
How to customize a 404 page under NGINX
There have been a lot of articles introducing the experience of customizing 404 pages under IIS and APACHE, and NGINX is still relatively few, and in order to solve its own problems, we have made in-depth research on it. The results show that configuring custom 404 pages under NGINX is feasible and simple with just a few steps:
1. Create your own 404.html page
2. Change nginx.conf to add fastcgi_intercept_errors on;
3. Change nginx.conf (or a separate site profile, e.g. site profile under nginx -> sites-enabled)
In the server region: error_page 404 /404.html or error_page 404 =http://www.xxx.com/404.html
4. Restart nginx after the changes, and test the correctness of nginx.conf: /opt/nginx/sbin/nginx –t
#502 and other errors can be configured in the same way.
error_page 500 502 503 504 /50x.html;
Notes:
1. Must add: fastcgi_intercept_errors on; If this option is not set, it will have no effect even if the 404.html is created and configured error_page fastcgi_intercept_errors Syntax: fastcgi_intercept_errors on|off Default: fastcgi_intercept_errors off Add location: http, server, location By default, nginx does not support custom 404 error pages, only this command is set to on, nginx supports redirecting 404 errors. It's important to note here that it's not that setting fastcgi_intercept_errors on will redirect the 404 error if nginx is set. 404 error redirects in nginx are valid if fastcgi_intercept_errors on is set and error_page option is set correctly (including syntax and corresponding 404 pages)
2. Do not designate the homepage as a 404 error page for the purpose of saving trouble or increasing the weight of the homepage, and do not jump to the homepage in any other way.
3. The customized 404 page must be larger than 512 bytes, otherwise IE default 404 page may appear. For example, let's say you customize a 404.html that is only 11 bytes in size (content: 404 error).
|
Previous:After the physical fitness test yesterday, I now have back painNext:Look at other people's designs, designers, you are too bad!
|