Fix WordPress with All Pages Returning 404 Not Found

April 10, 2020

Problem

I encountered a strange issue with WordPress: while the homepage loaded properly, all the other pages failed to do so. Instead, an error page displayed the message:

Not Found

The requested URL was not found on this server.

However, since I had migrated the files from another server, all the pages should already exist. I suspected that the .htaccess file might be the culprit, but after hours of troubleshooting, I still had no clue.

Solution

As it turns out, in my case, the .htaccess file was correctly configured. The issue lay elsewhere. To resolve it, edit the httpd.conf file:

    sudo vi /etc/httpd/conf/httpd.conf

Locate the section that starts with:

    <Directory "/var/www/html">

Change the configuration from AllowOverride None to:

    AllowOverride All

Finally, restart the server:

    sudo systemctl restart httpd

After doing this, all the pages should render properly.


Profile picture

Software development professional with expertise in application architecture, cloud solutions deployment, and financial products development. Possess a Master's degree in Computer Science and an MBA in Finance. Highly skilled in AWS (Certified Solutions Architect, Developer and SysOps Administrator), GCP (Professional Cloud Architect), Microsoft Azure, Kubernetes(CKA, CKAD, CKS, KCNA), and Scrum(PSM, PSPO) methodologies. Happy to connect