Website Guider

The Ultimate Resource for WPadmins and Geeks

How To Fix The WordPress Post Returning 404 Not Found Error

WordPress is easy to use but we get stuck when having any problem with it. You should be able to handle these problems.

Many a time the problems are created when doing tweaks to the core files of WordPress.

But WordPress is a user-friendly CMS so finding a solution to a problem is easy. One of the common error is ‘404 Not Found’.

The error is caused by the server because of the URL requested by the user is unavailable. You shouldn’t worry about the data on your site, the error is only shown to a user or visitor.

But you should fix this as soon as possible. Here we go with our topic ‘How to fix the WordPress Post Returning a 404 error’.

The 404 errors are created by bad permalink structure in many cases.

The permalink structure is controlled by a file located in the WordPress core called .htaccess.

From above we can say that the 404 error is caused by two reasons.

  1. Bad Permalink Structure
  2. Corrupted .htaccess file

Let’s move towards the solution first.

#Solution 1: Reset Permalinks 

Resetting the permalinks is the easiest way to get rid of this problem.

When doing this method, the .htaccess file is replaced by a new one. This method can be easily done through WordPress dashboard.

To do this, Go to WordPress Dashboard and hover the Settings tab and then click Permalinks.

After that set the permalink structure as ‘Post Name’ and click ‘Save Changes’.

Permalinks

This method may resolve the issue of 404 Not Found. If not you can use another method cited below.

#Solution 2: Rewrite Rules Manually

This is also easy method but requires a little bit of experience with FTP client. You can use FileZilla for uploading files to the server.

You should have FTP login credentials which you can get from your hosting. Navigate to FileZilla software and enter details.

Now create a file in your desktop and name that as .htaccess and add this code to the file using NotePad or Code Writer.

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

 After doing all this take a backup of your .htaccess file and save it to your laptop. Now navigate to FileZilla and check is there any folder named as public_html or your websites name.

FTP Website Folder

Click on the folder and you will see the folders named as wp-admin, wp-content, wp-includes and many files.

But you wouldn’t see any file named as .htaccess. The reason is that .htaccess is a dot file and many FTP clients don’t show them.

In this case, you have to force the web client to show hidden files.

You can see at the top of FileZilla, there is a menu item named as Server, click on it and a sub-menu will be shown.

At last of sub-menu, you will see an option ‘Force Showing Hidden Files’  click on it.

.htaccess file

Now you can refresh web client and all hidden files will be shown. Download the .htaccess(backup purpose) and save it.

Download HTACCESS

Then delete the file and upload the file you created a few minutes ago. Refresh the FileZilla and check whether the error is gone or not.

Sometimes your site gets infected by malware that may be the possible reason. You can contact your host to optimize the core files.

Fix the 404 Error on a Local Server

Many developers and designers use local development for their clients. What if you are getting a 404 Not Found Error on locally hosted site.

If you are using Desktop server or IWP, you can apply above methods to get the problems solved.

If you are running local server using MAMP, WAMP, or XXAMP, then you have to do another method.

Navigate to local server>>Apache>>Apache Modules and check whether the rewrite modules option is checked or not.

If checked then you can do another method. Navigate to local server>>Apache>>Apache Modules>>httpd.conf. Open the httpd.conf and locate the line

#LoadModule rewrite_module modules/mod_rewrite.so. Remove the pound or hash sign and save the file. You are all done.

Note – If you are a beginner, I am helping beginners with more support. You can use ‘Need Help’ form and I will do my best to better support you. You can find ‘Need Help’ form at bottom of About page.

Hope you liked this tutorial, if so please like, share and have your valuable comment.

Raashid Din Dar

Raashid Din Dar is a web developer and designer. He specialises in WordPress Theme and Plugin development. Also, Web Designing is what he loves.He loves to read books and play with friends.

Leave a Reply

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

Back to top