How to redirect 404 error page to any page in WordPress

Posted In: Tutorials, Wordpress, By , 4 Comments
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.

advertisement

 

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.
  • Pingback: Tweet Parade (no.51 Dec 2012) | gonzoblog()

  • http://www.pixelcrayons.com/ PixelCrayons

    Ahan, now this is something interesting. Fruitful information for WordPress users. Thanks!

  • cedooajl20

    nJZT – Lately i was REALLY down on money and debits were eating me from all sides!! That was RIGHT UNTIL i found out how to generate money.. on the Internet! I landed on surveymoneymaker point net, and started doing surveys for money, and yes I’ve been really more able to pay my bills!! i am so happy, that I did this.. – eePH

  • http://www.webcrayons.biz WebCrayons

    A very nice post for WordPress Developers , Thank you for sharing this information with us.