WordPress throwing 404 -Page not found

In this article we will learn how to solve wordpress throwing 404 error, the Page not found error. In this problem you may only see the Home Page and all other pages will throw 404 – Page not found, so make sure you refresh the Home Page, after trying each solution and then look for your pages. There are many possible solutions to this problem, it may work by applying only one solution from below or you may have to try it, in combination of 3-4 solutions. I struggled a lot to solve this problem, whenever i deployed worpdress sites for my clients, one solution worked somewhere and other worked somewhere else. So I decided to write about all the solutions which may help you.

The first solution is to reset your permalink structure, this is the most common solutions, works for almost all.

Go to Your Sites WordPress Dashboard >> Settings >> Permalink
Now you have to select “Post name” radio button as shown in image below, and Click on Save Changes. If this doesnt work click on Save Changes twice, i know its weird but, it worked few times.

 

The Second Solution requires you to make changes in .htaccess file. This a hidden file in your wordpress directory.

Add below code to the file.

 

WordPress itself will try to make changes to this file but its possible that your server is is blocking wordpress from writing to this file. To confirm this problem. Go to the Permalinks setting page, look at the end of the page you may find some message like below :

If your .htaccess file were writable, we could do this automatically, but it isn’t…

So if you are using linux try below command, this command will give access to wordpress to make necessary changes to the file.

 

The Third Solution requires you to make changes to httpd.conf file or if you dont find this file look for apache2.conf. This file is located at /etc/apache2/apache2.conf. Find something like below in the file.

In the third section , the /var/www/ will be the path where your site is deployed, so this can vary depending on your server setup and site installation.
Change AllowOverride None to AllowOverride All like below

 

The Fourth Solution : now you need to enable the rewrite using below command

I hope it solves your problem, if you are still unable to fix it, comment down below. I will try to help.