How to redirect 404 to homepage in wordpress

Rate this post

Want to redirect 404 error page to your homepage in wordpress? Here is how

Login to your wordpress admin page http://website.com/wp-admin/
Go to “Apperarance” -> “Editor” -> 404.php

If your theme doesnt have 404.php page, create one under your theme directory wp-content/themes/themename/

Change or create your 404.php code to these

header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit(); ?>

What those code does is to tell browswer that page has moved permantly with 301 error code, then redirect to your home page.


Related Articles

Leave a Reply

Photo and Image Files
Audio and Video Files
Other File Types

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Notify of
Back to top button

Send this to a friend