How to redirect wordpress 404 pages to homepage with 301 for SEO

How to redirect WordPress 404 pages to homepage with 301 for SEO

when some one  comes to your site by a search query or redirection through link. it’s so embarrassing to show the error 404 page not found page.

Instead, we can show them some other page or redirect it directly to the homepage of the WordPress website.

this also leaves a bad impression and may create wrong results on the search results.

So, what we can do is just create a 301 redirection to avoid any penalties.
Its is also easy to setup this SEO friendly 301 Redirection.

Just Login to your WordPress admin >> Click >> Editor Under Appearance.This normally edits your current WordPress themes files.
Now >> click the 404.php file on the right top of the page and type the below code on it.

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

Delete any existing codes on it,  if needed you can copy and save it.

2 Replies to “How to redirect wordpress 404 pages to homepage with 301 for SEO”

  1. Pingback: Do you have a spam problem on this blog
  2. I use Akismet, Its simple free for some 80k comments check, just signup for a wordpress.com account and get a API to activate Akismet on your wordpress blog.

Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.