How can I redirect a 404 error page to the home page?

In some cases, it can be helpful if instead of an error page, there should be a direct redirect to the home page. From an SEO point of view, this is not recommended, but the solution for this scenario is quite simple.

Solution: Create your own 404.php file in the theme folder and insert the following code. To be on the safe side, the original 404.php (if available) should be saved in case you want to use it later.

header("HTTP/1.1 301 Moved Permanently"); 
Without cookies
This website does not use cookies or tracking. More information can be found in the privacy policy.