How to redirect 404 to homepage in wordpress

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

Login to your wordpress admin page
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.

Recommended For You

About the Author: Linux Tips

Leave a Reply

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

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