Asp.net website Error 404 page setting method page 1/2

Source: Internet
Author: User

What is Error 404?

An HTTP 404 error means that the webpage to which the link points does not exist, that is, the URL of the original webpage is invalid. This situation often occurs and is difficult to avoid. For example: the original URL address cannot be accessed because the webpage URL generation rules are changed, the webpage file is renamed or moved, and the import link is misspelled. When the Web server receives a similar request, A 404 status code is returned to tell the browser that the requested resource does not exist. However, no matter Apache or IIS, the default 404 error page of the Web server is very simple, dull, and unfriendly to users, and cannot provide users with the necessary information to obtain more clues, this will undoubtedly lead to the loss of users.

404 page Functions

The search engine uses HTTP status codes to identify the status of webpages. When the search engine gets an error link, the website should return a 404 status code, telling the search engine to discard the index of the link. If a 200 or 302 status code is returned, the search engine creates an index for the link, which leads to a large number of different links pointing to the same webpage content. As a result, the search engine significantly reduced its trust in the website.

How to check whether the custom 404 page can return the "404" status code

After setting the custom 404 error page, make sure that the "404" status code is returned correctly. The check method is also quite simple. Enter a URL without a webpage in the website, check the HTTP header returned, and make sure it returns the "404" status code.

404 correct page practices

1. How to set the 404 page of Apache server

Add the. htaccess FileCode: Errordocument 404/error.html

Create a simple html404 page named error.html

Place error.html in the root directory of the website.

2. Set the 404 error page in IIS/Asp.net

First, modify the applicationProgramSet the root directory, open the "Web. config" file to edit it, and add the following content to it:

<Configuration>
<System. Web>
<Customerrors mode = "on" defaultredirect = "error. asp">
<Error statuscode = "404" Redirect = "notfound. asp"/>
</Customerrors>
</System. Web>
</Configuration>

In this example, "error. asp" is the default 404 page, and "notfound. asp" is the custom 404 page. Modify the file name when using it.

Then, add the following content to the custom 404 page "notfound. asp:

<%
Response. Status = "404 Not found"
%>

In this way, you can ensure that IIS returns the "404" status code correctly.

Reminder

1. Do not direct the 404 error to the website homepage, which may cause your website homepage not to be indexed;

2. do not include the primary domain name before/error.html (incorrect syntax: yzznl.cn/error.html, and error.html). Otherwise, the returned status code is 302 or 200.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.