How to redirect error 404 to home page in WordPress



If you don’t have a 404.php INSIDE your theme folder – WP displays the main (index) page when page not found, without you messing with the htaccess.

If this doesn’t work, put this code into a file named 404.php :

<?php header("Status: 301 Moved Permanently"); header("Location:"); ?>

( is your domain name)

Upload 404.php into /wp-content/themes/classic/    – change “clasic” to your theme name


WordPress Not Found Error after this?


The Cause of a WordPress Not Found Error.Why did this happen in the first place?

This error is most likely due to the fact that you’ve changed your WordPress permalink structure. The settings for your permalink structure are found in your Admin panel, under Settings » Permalinks. Basically, it lets you choose how the URLs of your WordPress site will look.

The default is always the first radio button, which says “”. However, if you’re like me – you’d rather have something more search engine friendly like “” — and you probably selected the last option which says “Custom Structure,” then saved the change. This is where the error occurs.

Here’s the reason why: by default, your .htaccess file is CHMODded to 644: disallowing WordPress to successfully edit it. You’ll even see the message in your admin panel under “Permalinks” that says this:

If your .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.

It is very easy to look past this message due to the fact that it’s at the bottom of the screen, appearing in italics, and nearly blending in with the box above it. Anyway – in order to successfully change your permalink structure, you would have had to make the permission settings of your .htaccess file more lenient, so that WordPress can be able to write changes within it.


How to Fix the Error ?


Don’t worry, it’s super easy…and quick

To remedy this problem, simply FTP into your website space and right click your .htaccess file. Change the settings or “file attributes” to 666. Go back to your Permalinks page, choose the link structure you want, and save it. Now, it works!

Don’t forget to go back to your FTP space and CHMOD your .htaccess file back to 644 – otherwise, it’s a major security risk!

  1. Get into your website’s FTP space, and look for the .htaccess file
  2. Highlight the .htaccess file in your FTP program, and open its CHMOD settings. It’s probably set to 644. Change it to 666.
  3. Go back into your WordPress site’s admin section, and navigate to Settings » Permalinks.
  4. Edit the link structure to whatever you originally wanted (I recommend that you use /%category%/%postname%), and then save it. You should no longer see a “grayed out” .htaccess box on this page, saying that the file is not writable.
  5. Visit any page of your site and confirm that the error no longer happens. If not, congrats!
  6. Finally, as a security measure, go back to your FTP space and change your .htaccess file back to 644, since you probably will never have to edit it through the WordPress admin panel ever again.


2018-11-19T12:17:57+00:00By |

Leave A Comment

19 − one =