Home > Backend Development > PHP Tutorial > Nginx custom 404 page (configured in Linux environment)

Nginx custom 404 page (configured in Linux environment)

WBOY
Release: 2016-07-29 08:59:55
Original
1237 people have browsed it

404 error is a common error when accessing WWW websites.

The most common error message: 404 NOT FOUND. The settings of the 404 error page have a great impact on the SEO of the website. Improper settings, such as direct redirection to the homepage, etc., will be demoted and plucked by search engines. The purpose of the 404 page should be to tell the user that the page you requested does not exist, and to guide the user to browse other pages of the website instead of closing the window and leaving. Search engines use HTTP status codes to identify the status of web pages. When a search engine obtains a bad link, the website should return a 404 status code to tell the search engine to abandon indexing the link. If a 200 or 302 status code is returned, the search engine will index the link, resulting in a large number of different links pointing to the same web page content. As a result, search engines’ trust in the website has been significantly reduced.


  1. First open the nginx.conf file and add

    fastcgi_intercept_errors on;

    (note, include the ; number) under fastcgi_temp_file_write_size 128k;Then add the site that needs to be defined inside (the author The file is the lbinin.conf file in the

    /alidata/server/nginx/conf/vhosts
  2. directory)
  3. Add error_page 404 = /404.html;

    under

    root /alidata/www/lbinin; (/404.html means placing the customized 404.html in the server root directory) Similarly, if you want to add a 403 page, the code is: error_page 403 = /403.html;

    Then save , restart nginx.

  4. Start, stop and restart nginx under Linux

/etc/init.d/nginx start/stop/restart/reload

For example, start nginx: /etc/init.d/nginx start


').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the Nginx custom 404 page (configured in Linux environment), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template