How to redirect 404 error page to any page in WordPress

Posted In: Tutorials, Wordpress, By , 4 Comments
advertisement

advertisement

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.

 

Option 1

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'));
?>

Option 2

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");
?>

About the Author:

Web designer/developer holding Masters degree in IT, currently living in Australia. Passionate about Wordpress, PHP, Fireworks and Jquery.