SEO

How to Redirect WordPress 404 Not Found Page to Homepage

Most of the time, WordPress 404 not found page does not provide much valuable information to the visitors who stuck at that page. One of the solutions is to redirect it to more meaningful page, especially the Homepage.

Although some people may argue, the usefulness of the redirects. However, I prefer to do so on some of my websites. The following procedure, guides on how to redirect.

  1. In WordPress admin area, head up to “Appearence” & click on “Editor”
  2. On the right hand site, click on file “404.php”. File description is “404 Template”.
  3. If the file does not exist, create one. If it does replace it with the following code & click save.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit();
?>

However, if you want to redirect to other pages, use the following code but remember to replace “YOURPAGEURL” with your page URL. Make sure you leave the open & close quotes.

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