How to 301 Redirect All 404 Error Pages to Homepage in WordPress

How to 301 Redirect All 404 Error Pages to Homepage in WordPress

404 Not Found errors are generated when a user follows a broken/dead link. You’d be amazed how many 404 errors even the best websites have.  The quickest fix is to redirect your 404 errors to your home page.Almost every theme that you use with your self hosted WordPress Blog have an inbuilt 404 Page (404.php), which you can customize as per your site/blog requirements

Two advantages we get when we are using this method

  • Search Engine Ranking will not be affected in any way, as we are using 301 Permanent Redirection here
  • The above trick will actually remove ALL exiting 404 Not Found Errors from Google Webmasters Tools and Bing Webmasters

1. Find 404.php in the activated theme, e.g Twenty Eleven (wp-content/themes/twentyeleven)

– Backup 404.php

– Login to your WordPress Dashboard and head over to Appearance > Editor.

– Click 404 Template (404.php) to open it in Editor windw

– Delete all code in 404.php file and enter following lines of code in it:

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

– Hit the Update File Button

2. Some themes don’t have 404 Template file or 404.php

– Create 404.php with Text Editor, e.h Notepad++

– Add the following code

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

– Upload this new 404.php to theme directory

  • http://www.techprevue.com/ Vinay Prajapati

    what does it means?
    <span class="hiddenSpellError" pre=""-->