How to set the 404 error page for apache and. htaccess

Source: Internet
Author: User

Setting the 404 error page for Apache Server is simple. You only need to add the following content to the. htaccess file:
 

The code is as follows: Copy code
ErrorDocument 404/notfound. php

Note:
1. Do not redirect the 404 error to the website homepage. Otherwise, the homepage may disappear in the search engine.
2. Do not use an absolute URL (for example, http://www.111cn.net/nokia/n96/form). If you use an absolute URL, the returned status code is "302" + "200" (tested)

The correct method is to add in. htaccess

The code is as follows: Copy code
ErrorDocument 404/404 .html

Instead

The code is as follows: Copy code
ErrorDocument 404 http://www.xxx.com/404.html

The former returns a 404 status code,

The latter returns a 200 status code. If the content of a 404 page is smaller than 404 B, IE considers the 404 page unfriendly and will not return the error page in IE.

In summary, if another friend is using an absolute path for 404, immediately modify it. Otherwise, your return status is 200, these are only about apache 404 page settings in iis. Remember to set them to a relative path when setting them. Otherwise, the system will return the 200 status code instead of the 404 code, I have done something wrong before, and everyone knows the result.

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.