Skip to content Skip to sidebar Skip to footer

How to Redirect 404 Page to Homepage, Without Plugin

Actually, a 404 page is not that much of a problem if it is found on our website, but for some publishers the report on Google Search Console regarding a 404 page not found is very annoying, including for myself.

Well, luckily solving this problem is not that difficult, WordPress users can solve it by redirecting to the homepage.

So when a visitor accesses a page that doesn’t exist or has a 404, it will automatically be redirected to the homepage, thereby reducing reports of pages not found in the Google Search Console.

How to Redirect 404 Page to Homepage, Without Plugin

Following are the steps to redirect a 404 page via our hosting cpanel,

  1. Login to your respective cpanel account
  2. Go to your file manager – public HTML or WordPress folder
  3. Go to wp-content -> themes
  4. Select the theme file that you are using, then look for the 404.php file or if it doesn’t exist yet, just create a new file with the name 404.php
  5. After that, paste the following code in the file
https://domainkamu.com/");exit();?>

Finally, just save, if you use the cache plugin or Cloudflare, you can purge the cache first, after that try to test finding a random page that is not on your website, then it will automatically be redirected to the homepage.

Make sure you adjust the URL above to your domain name.

Closing

That’s a simple way to redirect a 404 page to the homepage for the WordPress CMS. I hope this helps.