404 pages are mostly ignored by webmasters. But, on the contrary, these pages should not be ignored and they should be used to redirect your visitors to the right page. Here’s a short tutorial on how you can redirect your 404 page visitors to home page or any other page in WordPress.
Sometimes when coding a theme/website, developers may don’t have much time to design and create the 404 page. Or you may simply want to redirect 404 page visitors to any custom or specially designed page of your website. Use the below code to redirect the 404 page to your site’s home page or any other page of your choice.
If you already have a 404.php file in your theme’s root folder, then you will need to remove all its code and paste the below code. And if you don’t have any 404.php, then create a blank 404.php file and add below code in it.
Replace the URL part to your home page or any other page of your choice, where you want to redirect your visitors to.
That’s all you need to do. Now whenever a user stumbles upon a 404 page, the page will redirect your user to the home page or any page of your choice.
Note: Before editing 404.php, we would always recommend you to backup your original file.