iis6, iis7, apache dedicated IP host 404 error page setup (applicable to VPS cloud host servers)
Published: 2010-10-14
Setting a good custom error page can increase website indexing and retain customers who may give up because a page cannot be opened. Our virtual hosting service especially provides custom error page settings, and all custom errors, including 404 errors, can be set.
Virtual hosting setup method: http://www.west.cn/faq/list.asp?unid=810
linux system setup method:
Step 1:
Create a text file locally and add the following statement in it: ErrorDocument 404 /404.html Then upload it to wwwroot and rename it to .htaccess. If this file already exists in the website directory, download it, open it with an editor, and add the above rule.
Step 2:
Upload your own 404 prompt file and rename it to 404.html. You can also use other suffixes, as long as the same file is specified in .htaccess, for example: ErrorDocument 404 /404.php Note: Some programs have built-in pseudo-static rules that may conflict with the 404 settings. If this happens, you can only contact the program provider to debug the pseudo-static rules.
windows2003+iis6 system setup method:
First, create a 404.html file and place it in the root directory of your website, or in another directory. For example, create an HttpErrors directory and place it in that directory. At the same time, you need to grant the 404b.html file read permission to NETWORK SERVICE, otherwise the setting will not take effect.
Then open IIS (Internet Information Services (IIS) Manager):

Find the corresponding site, click "Properties", and then select "Custom Errors":

Find HTTP Errors, then the corresponding 404 below, and click "Edit"

For Message Type, select "File" and specify the 404 file in the website directory.
Then grant the 404 file Everyone read permission. Right-click the 404 file -- Properties -- Security, add Everyone read permission, as shown in the figure:

After setting it up, you can test it by adding a nonexistent suffix or file name after your site. If the setup is successful, your custom error page will be displayed.
If the 404 page to be set is a dynamic program file (for example, PHP), please select url. Note that if the file is in a subdirectory, change it to the form /xxx/404.php.

(Note: In windows hosting, the 404 error page file must be larger than 512 bytes. If it is smaller than 512 bytes, and if friendly error messages are enabled in Internet options, users will see the client default error instead of the custom error when accessing. In this case, you can try granting the 404b.htm file read and execute permissions to the IIS_WPG group, and then test it.)
windows2008/2012+iis7 (and above) system setup method:
First, create a 404b.htm file and place it in the root directory of your website, or in another directory. For example, create an HttpErrors directory and place it in that directory. At the same time, you need to grant the 404b.htm file read permission to NETWORK SERVICE, otherwise the setting will not take effect.
Then open IIS (Internet Information Services (IIS) Manager):

Click the Error Pages feature.

Double-click the 404 row to enter settings. Generally, choose the first or second method to set the path to your corresponding 404 file. In addition, note that you need to change the configuration to Custom Error Pages.

If you specify a dynamic script URL, the status code returned will be 200. If you need to return a 404 status code, you need to add response header information in the 404 file, as follows:
For ASP, add:<%Response.Status="404 Moved Permanently"%>
For PHP, add:<?php header("HTTP/1.0 404 Not Found")?>
If it is a static file, use the following method to directly return a 404 status code.
IIS7 static page adding 404 error page, method to return status code 404:

Note that the file path here needs to be in the root directory; directly fill in the name of the 404 error page.

Select File as the path type.
