How to customize WordPress404 error pages

Source: Internet
Author: User
Tags wordpress blog
404 is one of the HTTP status codes specified by W3C. It is a common error during WWW website access. The most common error message is 404 NOTFOUND. The 404 page indicates that when the user inputs an incorrect link

What is error 404?

404 is one of the HTTP status codes specified by W3C. It is a common error during WWW website access. The most common error message is 404 not found. The 404 page is the page returned when the user inputs an incorrect link.

Cause of 404 error

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. Generally, there are three reasons for this error:

1. you cannot access the Web site on the requested port.

2. the Web service extended locking policy blocks this request.

3. the MIME ing policy blocks this request.

How to handle 404 errors

You can create a more user-friendly 404 page. The purpose is to tell the viewer that the requested page does not exist or the link is incorrect. at the same time, the user is guided to use other pages of the website instead of closing the window and leaving. Many open-source systems, including CMS and Blog systems, do not provide 404 pages or provide 404 pages, which does not meet the SEO requirements, which greatly compromises the website's authority.

WordPress is not satisfactory in handling 404 errors. although its template has its own 404 error page, this 404 page is indeed convenient, but when your website has been working for a long time, there are likely to be a large number of 404 pages. for example, if I used to build an information website and changed it to a wordpress blog, a large number of 404 pages will appear, the search engine will continue to access these non-existent pages, which increases the burden on the server. using htaccess to customize a static 404 page can solve this problem.

Next we will introduce how to customize the 404 page.

1、the first step is to create a new 404.html static file and upload it to the root directory of the website.

2. delete the original URL rewriting rule file htaccess and add the following rules.

# BEGIN WordPress

ErrorDocument 404/404 .html

RewriteEngine On

RewriteBase/

RewriteRule ^ archives/. * $/index. php [L]

RewriteRule ^ feed. * $/index. php [L]

RewriteRule ^ page/. * $/index. php [L]

RewriteCond % {REQUEST_FILENAME }! -F

RewriteCond % {REQUEST_FILENAME }! -D

# END WordPress

Archives is the url format of an article, such as/archives/188. you can modify it based on your actual article url. If your blog is installed in the WordPress directory, you must add RewriteRule ^ wordpress/. * $/index. php [L].

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.