WordPress site redirect missing pages to the homepage
If you are using WordPress and have updated a website, chances are that many links from your older site are outdated.
There is a simple way to avoid showing visitors a 404 page.
Just create a file called 404.php and upload it to your active theme folder. This file will make WordPress produce a 301 redirect to the homepage or any other URL you may like for all missing URLs on the site.
header(“Status: 301 Moved Permanently”);