A regular website, gets about 10-15% not found hits in a month. If you can’t handle those hits in a good way, visitors will leave your site with dissapointment. Of course, a custom, well organised 404 page is the best way to handle them, but you can also redirect them to your home page for fresh content.

To redirect 404 hits to your blog home page, just add following code to your functions.php file:

function shailan_redirect_404() {
    global $wp_query;
    if ( $wp_query->is_404 ) {
      wp_redirect( get_bloginfo('wpurl'), 301 );
      exit;
    }
}
add_action('template_redirect', 'shailan_redirect_404', 1);

This code checks wp_query if a 404 page needs to be generated. If that’s true, it will redirect user to homepage instead of 404.php.