FIX 404 ERROR ON WORDPRESS DUE TO MOD_REWRITE NOT WORKING

In WordPress and Joomla website .htaccess files are used to ensure that the pages redirect properly to links created using the CMS.

If this is not enabled at the server level for /var/www/html, even if mod_rewrite is enabled (which it is on CentOS 7 by default), you will get a 404 error.

First, ensure mod_rewrite is actually enabled in the first place.

httpd -M | grep rewrite

If you see:

rewrite_module (shared)

It is enabled so on to the next step by editing /etc/httpd/conf/httpd.conf.

In the following section between <Directory “/var/www/html”> and </Directory>

Change:

AllowOverride None

to

AllowOverride All

Then restart Apache:

systemctl restart httpd.service

You should now be able to navigate using your WordPress site correctly.