Permalinks, .htaccess and 404 errors on every page but the home page

A very recognisable fault: the home page loads perfectly and every other page returns 404. The pages exist and look fine in the admin. This is almost always the permalink rules missing from .htaccess.

The quick fix

In WordPress go to Settings, then Permalinks, and click Save without changing anything. That rewrites the rules into .htaccess. Nine times out of ten the site returns immediately.

If that does not work

WordPress can only write the rules if the file is writable. Check that .htaccess exists in your public_html and is set to 644. If it is missing, create it and paste in the standard block:

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

Watch out for security plugins

Some security plugins write their own large blocks into .htaccess and rewrite the file regularly. We have seen one append its block repeatedly until the file contained dozens of copies of the same rules. If your .htaccess is unexpectedly long, or full of repeated sections, that is what has happened – and it can push the WordPress rules out of position.

Take a copy, cut it back to the standard block plus whatever you genuinely added, and then look at the plugin's settings.

WordPress in a subfolder

If WordPress is installed in a subfolder, RewriteBase and the rewrite target must both reflect that folder. Copying rules from a root installation is a common cause of this exact fault.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Why WP-Cron is disabled on our servers, and what replaces it

WordPress has its own scheduling system, WP-Cron, which runs scheduled tasks – publishing...

Object caching, and why Redis is not available here

WordPress can store the results of database queries in memory so that repeated requests do not...

Moving an existing WordPress site to us

A move goes wrong in predictable ways. Doing it in this order avoids all of them. 1. Set the...

The white screen of death: how to diagnose it

A completely blank page means PHP stopped part-way through and had nothing to show. The page...

Locked out of wp-admin: how to get back in

There are several routes back in depending on what is wrong. All of them need cPanel access, so...