All for Joomla All for Webmasters
WordPress

WordPress: How to fix page not found error (404)

Despite being the most used Content Management System and usually the first choice for most developers, WordPress has some configuration issues that may break your entire website. One of most commons errors that happens using that platform is about the permalinks error, causing a not found message for every post and page.

Fixing WordPress posts returning 404 error

When I faced this problem, I found many approachs to solve it and it may be necessary to perform all those steps to fix the error. I’m gonna show all those approachs ordered by how probably it can fix the issue, in a way that when you go through those steps, you can constantly check if the problem was already solved so you don’t need to go along.

REFRESH PERMALINKS

Permalinks is what WordPress uses to manage the path to your posts and pages. It’s usually defined by the post name, since it’s a more friendly URL. So, the first approach is basically to access the permalinks configuration (Settings >> Permalinks) and click on save button (don’t need to make any changes).

Update permalink settings

That action will refresh the permalinks on your database, which solves the problem for most cases. Anyway, depending on the access permissions on your server, it may be necessary to edit your .htaccess file. On your server, you can find the .htacess file on your WordPress root folder (where’s located another folders like wp-content, wp-includes, etc). You have two options: the first one is to change your file permissions before redo the previous step:

You can also edit the file manually to insert the content that WordPress is trying to append when you click on save button:

This is the trivial solution and it works for most cases. However, there may be also some other configurations on apache server that can be blocking file’s rewrite.

ENABLE MOD_REWRITE ON APACHE

In some situations, the rewrite module for apache needs to be enabled for updating the file. You can enable that module running:

Then, you must restart apache server:

After restarting the server, you gotta redo the first step to refresh the permalinks. In my case, those steps still weren’t enough to fix the issue, so I still had to change another apache configuration file, which is explained on next step.

UPDATING APACHE CONFIGURATION FILE

Apache’s config file is located at “/etc/apache2/apache2.conf” in it latest version. It may be necessary to include a configuration block that allows override for WordPress directory. Suposing that your application is located at “/home/ronanlopes/ronanlopes”, for example, you must include this piece of code for the server’s configuration:

Again, you’ll have to restart the server and redo the step for refreshing permalinks. This last step was the one that solved my problem, but if you’re lucky you won’t have to reach all the way through here. If you have any doubts or suggestions, please use the comment area or contact me.

1 Comment

  • Reply
    Sannytet
    December 11th, 2018 at 20:19

    Nice posts! 🙂
    ___
    Sanny

  • Leave a Reply