How to Fix WordPress Posts Returning 404 Error

The WordPress 404 error is quite a common error in WordPress and relatively easy to fix. The error often shows up after a manual installation of WordPress, an upgrade or migration of a WordPress site from a subfolder to the root.

I will show you how to correct this very common error from either right inside your WordPress installation or by manually editing your .htaccess file.

Meaning of WordPress 404 error

The WordPress 404 not found error means that your hosting server for some reason was not able to locate the specified post or page.

Obviously this could be caused by the fact that the post or page in question has been removed from your website hence the server can not find it any more. Sometimes, however, the post is actually present but a technical error is causing your server problems resolving your request.

This error will sometimes just show up out of the blue but quite often, it manifests after an upgrade to the core WordPress script.

When the 404 error occurs, it might affect your index page alone or affect several other posts and pages while your index page works properly, or affect the entire website.

The 404 error is a very common error and if you have been working with WordPress for years as we have, you will most likely have come across it. Needless to add, the error is also fairly easy to solve.

This article will help you fix your 404 error but if for some reason you need professional help, you can contact us and we will fix it for you for a small fee of just $15. Click here to order

How to Fix WordPress Posts Returning 404 Error

If you are sure your content was not deleted, then this problem indicates an error with your links. You must ensure that there are no misconfigurations leading to this 404 error. Depending on your situation, there are four (4) possible ways to solve this error.

The commonest cause of this error is .htaccess error. A bad syntax in your .htaccess could make your website fail to read files properly and cause this error. If this is the case, simply adjusting and saving your permalinks will often solve the error. You can then adjust back to your prefered permalinks structure and save again. In WordPress, saving your permalinks forces a .htaccess file update and will most likely solve any .htaccess misconfigurations for your WordPress website.

In order to adjust and save permalinks,

  • login to your WordPress dashboard with your admin username and password.
  • Go to left menu and choose permalinks under – Settings > Permalinks.
  • Select the desired permalinks structure.
  • Scroll to the bottom and Save your Changes.

If this error was caused by a wrong .htaccess configuration, upon saving your .htaccess file will be updated and all faulty commands should be corrected.

Please note that your .htaccess file needs to be writable for the changes to work.

If the file is not writable, use your favourite FTP client or file manager to change its file permissions. You may also use the next method instead.

This method might be useful where you are unable to have method one performed successfully for one reason or another.

In this method, you will have to manually edit your .htaccess file and fix any problems that might be causing your WordPress website not to display well.

To edit your .htaccess file, you will have to either use your inbuilt file hosting manager or access your website files using an FTP client like Filezilla.

If you are using the hosting File Manager, you do not have to download, you can edit your .htaccess file directly on the server by right-clicking and selecting edit code. Remember to save after editing.

Edit Code in cPanel
Edit Code in cPanel

If you can not see your .htaccess file, it’s possible that the server is hiding it. In cPanel you will have to look for settings in the top right corner and enable show hidden files.

Show Hidden Files in cPanel
Show Hidden Files in cPanel

If you are using an FTP client, you have to download the file edit and upload it back on to the server.

Whichever method you use to edit the .htaccess file, Select the situation that best describes your WordPress installation and edit accordingly.

A) WordPress Website Installed in Root Directory.

If your WordPress website is installed in the root folder of your hosting environment, add this code to your .htaccess file:

# BEGIN WordPress

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

# END WordPress

After editing and uploading the file, refresh your site and access posts and pages to see if this fixes your issue.

How do I know My Hosting Root Directory?

Depending on the hosting control panel you are using, your root directory is most likely going to be:

  • Plesk – httpdocs.
  • cPanel – public_html
  • Some others – html

B) WordPress site Installed in a subdomain

If your site is installed in a subdomain, your link will most likely look like or something similar.

If your WordPress website is installed in a subdomain, you need to edit your .htaccess file and add in this code.

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

C) WordPress Installed in a Subfolder inside root.

If your WordPress website is installed in a subfolder or subdirectory inside your main/root directory, it will most likely be accessible on a link similar to

If your installation is in a subfolder, edit your .htaccess and have this code inserted if not yet present.

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

Was this Helpful?

YOU MAY ALSO READ:   Install WordPress On Your cPanel Server

Leave a Reply

Your email address will not be published. Required fields are marked *