How to Redirect Visitors From 404 Page to Home Page

From this tutorial you’ll learn how to redirect visitors from 404 page to Home page.

Redirecting Visitors From 404 Page to Home Page
  • First, enter your hosting server and proceed to cPanel file manager.
  • Locate wp-content/themes/theme_name folder, where theme_name is your actual theme name.
  • Create a new file in this folder. To do it click on New File button. Your file should be called 404.php.
    If you’re using a template under GPL v.3 license, this file already exists!
  • Open the file using Edit button and add these lines of code.

https://gist.github.com/Shininglow/560fc0fb556886f3742f43c4946d9e46

  • Save the applied changes and refresh your website. Now your visitors will be redirected from 404 page to your website’s Home page.
  • Let’s check if 404 page works. To do it type in the unexisting address on your website. You’ll be redirected to your website’s Home page immediately!
This tutorial is based on Movie Responsive WordPress theme.