Complete Guide To Redirect 404 Page To Homepage In WordPress

 

Image result for Redirect 404 Page To Homepage In WordPress

How to redirect 404 page to homepage in wordpress ? This is the most common question every wordpress user is having. So, today i thought to write the complete tutorial to redirect 404 pages to homepage.

So basically in this wordpress tutorial we gonna learn couple of things like

  1.     What is error 404 page not found.

  2.     How to redirect 404 page to homepage.

  3.     How to redirect 404 page to any specific page.

  4.     What Is 404 Error Page ?

Whenever your user or visitor landed on non existing/broken url then he/she will be shown the default wordpress 404.php error page. This simply shows that the url you are looking for doesn’t exist or removed”.So by seeing this page your user may not search any other page/post and they simply exit from your blog. So what basically happened in this case is you loose your readers. Now, question is what to do, to not loose those loyal readers ? any idea ?

The answer is, you can simply redirect your broken or non existing links to your blog homepage. This will also improve SEO search engine optimization of your blog.

How To Redirect 404 Page To Homepage In WordPress ?

This is very simple. All you have to do is just paste one code snippet in your 404.php file. Just follow the simple steps written below to execute this task.

Step 1 :- In admin area, Go to Appearance >> Editor.

Step 2 :- Open 404.php file.

If it doesn’t exist then simply create new blank php file and rename it.

Step 3 :- Paste the below code.

<?php

header(“HTTP/1.1 301 Moved Permanently”);

header(“Location: “.get_bloginfo(‘url’));

exit();

?>

That’s all. Now whenever your user landed on deleted or non existing url, they will be redirected to homepage of your blog. How To Redirect 404 Page To Any Specific Page In WordPress ?

You might do not wanted to redirect 404 page to homepage but instead you wanted to redirect it to any specific post or page of your blog. Then in that case you need to give specific url of your post or page. Just follow the simple steps below to execute this task.

Step 1 :- Repeat step 1 and step 2 from above part.

Step 2 :- Paste the below code.

<?php

header(“HTTP/1.1 301 Moved Permanently”);

header(“Location: “.get_bloginfo(‘url’).”http://solvemyhow.com/404”);

exit();

?>

That’s it. Now your user will be redirected to specific page or url of our blog post. Here you may redirect your user to your custom created 404 page too.

Bhardwaj Brothers
Founder

Hey Readers, Welcome to my blog ByNext. I’m Akash Bhardwaj, a professional-blogger from New Delhi, India.


I started ByNext as a passion and now it’s empowering more than 500,00+ readers globally and helping them to make money with their blog.


Here at ByNext I write about Starting & managing a blog, WordPress, Social-media, SEO and Making Money online.


Leave a Reply

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

Optimization WordPress Plugins & Solutions by W3 EDGE