How to use the htaccess custom WordPress page 404


when you see this title, you may have two questions: 1, why should their own definition of a 404 page, WordPress template is not take 404.php to handle not exist page? I want to say is, this 404 page really convenient, but when you do the site in time long, it is likely there will be a large number of 404 pages, for example, used to be a kind of information website, after revision wordpress blog, there will be a large number of 404 pages, and the search engine will continue to access these pages do not exist, thus increasing the burden on the server, and the use of a custom htaccess static page 404, we can solve this problem. 2, the use of htaccess custom WordPress 404 page that is not simple, directly in the htaccess file to add the code ErrorDocument 404 /404.html, then a new 404.html file upload to the root directory on OK. But this method is not feasible, because the default rewrite rules is to make all requests to index.php script, but also does not exist page, if 404 pages directly add common setup code, will not have any effect. Said so much, I believe you have to understand why WordPress is a custom 404 page. Here we describe how to customize the page 404.

#%{!

2, delete the original rewrite rules htaccess file, add the following rules are as follows.

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, such as /archives/88, can be modified according to their actual articles url. If your blog is installed in the WordPress directory, you must increase the RewriteRule ^wordpress/.*$/index.> in the back

1, the first step of course is to create a 404.html file, and uploaded to the site root directory

Leave a Reply

Your email address will not be published. Required fields are marked *