Redirect all 404 to home page

How can I redirect all non-existing pages to the home page?

Add this code at the beginning of your 404.php template:

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

Submit a Comment

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