Illegal websites should not initiate any form of manual service requests to our staff. It is strictly prohibited to use honmau Media's technical support services and products to engage in any illegal activities. If discovered, no technical support will be provided.×
Current location:home> news > help and support

How to configure 404 pages on Linux system server Nginx

In the Linux system environment, many Nginx configuration 404 pages return a status code of 200 instead of a 404 status code. Therefore, such 404 page settings are incorrect. Today, I will share the method of configuring Nginx 404 pages in Linux:

Follow the following 5 steps:

1. Create your own 404.exe page and place it in the website root directory;

2. Change nginx. conf to add in the HTTP definition area:

vi?/usr/local/nginx/conf/nginx.conf? Edit Nginx configuration file in HTTP? Add the following code to the section: fastcgi.interpept_ errors? on;

'Linux系统服务器Nginx配置404页面的方法'

3. Change nginx. conf? In the website configuration, on the server? Regional joining:

server{

error_page? 404? =?404.html;? #Just jumping around

}

'Linux系统服务器Nginx配置404页面的方法'

Most online tutorials use the code above, which returns a 200 status code. The correct setting is to remove the '=', as shown in the following code:

server{

error_page?404?404.html;

}

4. Test the correctness of nginx. conf:

?/usr/local/nginx/sbin/nginx?–t

Return the following code through:

the?configuration?file?/usr/local/nginx/conf/nginx.conf?syntax?is?ok

configuration?file?/usr/local/nginx/conf/nginx.conf?test?is?successful

5. Smoothly restart Nginx to complete the 404 page setup.

/usr/local/ws/nginx/sbin/nginx?-s?reload

In this way, when using webmaster tools to test the status code, the detected status code is 404, which completes the Nginx configuration 404 page setup under Linux.

Related explanation: When a user enters a website and clicks on a non-existent or deleted page, the website will display a prompt that the page does not exist. Many websites return a 200 status code instead of guiding the user back.

Precautions for creating 404 error pages:

1. Do not redirect 404 errors to the website homepage, such as www.honmau.com. Do not redirect all 404 errors to honmau.com or www.honmau.com, as this may result in the homepage being downgraded or disappearing in search engines;

2. Do not use absolute URLs. If an absolute URL returns a status code of 302+200, it will generate a large number of duplicate web pages;

3. The 404 page setup is complete, be sure to check if it is correct. The HTTP header information must return a 404 status. This can be checked through the server header information checking tool.

4. Do not automatically redirect to the 404 page, let the user decide where to go.

5. Custom 404 pages must be larger than 512 bytes, otherwise IE's default 404 page may appear.

© Website copyright and disclaimer

1.[honmau Media] independently owns the copyright of all materials on relevant pages of this website;

2. No one is allowed to copy it without the express written permission of [honmau Media];

3. The articles that do not indicate "honmau Media" on this website are all from the Internet and are only for everyone to learn and refer;

4. If there is any infringement/violation/irregularity, please contact customer service QQ or email to delete it, please understand;

5.[honmau Media] reserves the right to correct, modify and update this statement at any time.legal notice

Message Board
* Contact customer service for urgent issues
submitted
submission
Working days: 8:30 - 22:00 Online QQ

customer service

Company Introduction
top