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.
header("HTTP/1.1 301 Moved Permanently");
Delete any existing codes on it, if needed you can copy and save it.