How to redirect 404 error page to any page in WordPress
Error 404 page is quite crucial for any website. If any website leads to blank or error page whenever a page is not found or website URL is miss typed, you might loose lots of visitors and search engine ranking.
This tutorial will not only help you to redirect your WordPress error page to home page but also to specific page. It might be homepage, contact page or any custom page.
If some of your website page is listed on search engine which does not exist anymore, Erorr 404 page will help you keep visitors within your website.
Open 404.php inside your theme folder, if this page does not exist create a new one. Paste the code below to redirect error page to homepage in WordPress.
<?php header("Status: 301 Moved Permanently"); header("Location: ".get_bloginfo('url')); ?>
Copy and paste the following code inside 404.php to redirect it to any page, replace xxx with correct domain name and page name.
<?php header("Status: 301 Moved Permanently"); header("Location: http://www.xxx.com/xxx"); ?>