How to fix 404 Not Found error in WordPress

In this post, we are going to discuss ways of fixing the 404 Not Found error in WordPress.

Most developers will first design their WordPress websites on their localhost and then transfer it to their server. After the migration, even though you are able to access the homepage and the WordPress dashboard, it is possible to get the 404 not found error when accessing specific posts.

This can also happen when your .htaccess file is deleted by mistake or when there is something wrong with the rewrite rules.

We are going to discuss two methods that we can use to fix the 404 Not Found error in WordPress. They include;

  1. Resaving Permalinks
  2. Making edits to the .htaccess file.

Resaving Permalinks

This is the simplest method you can use to fix the 404 Not Found error in WordPress. 

Step 1:

The first step is to log in to the WordPress admin dashboard and then navigate to Settings > Permalinks as shown below;

WordPress Dashboard

Step 2:

You will be taken to the Permalinks page. Here, you do not need to make any changes. All you need to do is to simply click on the Save button at the bottom to resave the permalinks. 

After this, refresh your website and check all the pages and posts to test if there is any that still gives you the 404 Not Found error. This process creates a new .htaccess file.


Making Edits to the .htaccess File

You can also fix the 404 Not Found error in WordPress by making edits to the .htaccess file. To make the edits, you will need to access your website files and select the .htaccess file for edit.

You can do that by logging in to the CPanel of your website or using an FTP client such as Filezilla. In this post, I am going to log into the CPanel and edit the .htaccess file.

Step 1:

Using your server credentials, log in to the CPanel. This will take you to the homepage on the CPanel.

Step 2:

On the page above, click on File Manager under Files. This will take you to another page with all your website files. Click on the public_html folder on the left-hand side as shown below.

Step 3:

Depending on your settings, you might not be able to see all the files in this folder. In order for you to see all the files, you will need to change the settings. Click on the Settings button at the top right of the page above and select Show hidden files then save the changes.

Step 4:

You will notice that you can see more files than you were able to previously see. Locate the .htaccess file, click on it and select edit at the top.

Step 5:

The .htaccess file should have the following code. If it does not have it, you will need to manually write the code and save the file.

You can copy the code from below;

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule>

Save the file after writing the code then refresh your website. The 404 Not Found error will be fixed.


Conclusion

These two methods will help you fix the 404 Not Found error in WordPress. They are both very easy and do not require you to have any technical knowledge. However, you need to be careful when using the second method to avoid unnecessary issues with your WordPress website.

TheWphosting Staff

Leave a Comment