Reset WordPress permalinks
Fix pages returning 404 when the home page works, by regenerating the rewrite rules — from the dashboard, or by restoring .htaccess if you cannot log in.
When every page except the home page returns 404 Not Found, the rewrite
rules in .htaccess are wrong or missing. Regenerating them fixes it. Applies
to all shared and reseller hosting.
This is the classic symptom after a migration, a restore, or an edit to
.htaccess that removed the WordPress block.
From the WordPress dashboard
WordPress rewrites .htaccess whenever you save the permalink settings, so
saving twice regenerates the rules without changing anything.
- Log in to the WordPress dashboard.
- Go to Settings → Permalinks.
- Note the setting currently selected. If it is Custom Structure, copy the string somewhere safe first.
- Select Plain, then Save Changes. If Plain was already selected, choose Day and name instead. You should see Permalink structure updated.
- Select your original setting again and Save Changes. Wait for the second Permalink structure updated message.
Clear your browser cache before testing, and test in a private window — a cached 404 will otherwise convince you nothing changed.
If you cannot log in
Replace the WordPress block in .htaccess by hand. The file is in your document
root, normally public_html, alongside wp-admin and wp-config.php.
Use cPanel's File Manager with Show Hidden Files enabled, or an FTP client.
# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPressReplace only the block between # BEGIN WordPress and # END WordPress.
Overwriting the whole file discards anything else in it — redirects, security
rules, caching directives and settings added by plugins.
If the file has no WordPress block at all, add this one at the top.
Once you can log in again, save the permalink settings from the dashboard so WordPress owns the rules.
If it does not help
- A single page 404s, the rest work. That is not a permalinks problem — check the page exists and is published.
.htaccesswill not save. Check the file's permissions; it should be644. See Fix "Unable to create directory".- The site is in a subdirectory.
RewriteBasemust match —/blog/rather than/for a site atexample.com/blog.
Related
Fix a site stuck in maintenance mode
WordPress shows "Briefly unavailable for scheduled maintenance" when an update did not finish. Delete the .maintenance file to bring the site back.
Prevent LSCache from auto-installing
Flag a WordPress installation so WebGee's automated process does not install LiteSpeed Cache on it, and set the same exclusion for every new account.