If your home page loads but every post, page or category returns "404 Not Found", WordPress's rewrite rules are missing or overridden. Pretty permalinks such as /my-first-post/ rely on a few lines in .htaccess that send every request to index.php. This guide restores them.
Before you start
- Administrator access to WordPress.
- Access to cPanel → Files → File Manager, with Settings → Show Hidden Files (dotfiles) enabled so you can see
.htaccess.
Re-save the permalink settings
- Log in to
/wp-adminand open Settings → Permalinks. - Do not change anything; just click Save Changes.
- Reload one of the broken posts in a private window.
Saving makes WordPress rebuild its rewrite rules and, if it can, rewrite .htaccess. This fixes the problem in most cases, especially after a migration.
Restore the default .htaccess
If saving did not help, open the site's root folder in File Manager and edit .htaccess (create it if it does not exist). It must contain this block:
# BEGIN WordPress
<IfModule mod_rewrite.c>
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]
</IfModule>
# END WordPressKeep any lines other plugins added outside this block, such as LiteSpeed Cache rules, and save the file. Make sure permissions are 644.
WordPress in a subfolder
If WordPress lives in public_html/blog, the .htaccess belongs in that folder, and two lines change:
RewriteBase /blog/
RewriteRule . /blog/index.php [L]Look for conflicting rules
- An
.htaccessin a parent folder, for example inpublic_htmlwhen WordPress runs in an addon domain folder inside it, can override your rules. - Redirect rules added in cPanel → Domains → Redirects are written into
.htaccesstoo. Check they are not catching all URLs. - Security plugins sometimes add blocking rules. Rename the file to
.htaccess-old, add only the default block and test.
Only some URLs return 404
- Custom post types or a new plugin's pages: re-save permalinks after activating the plugin.
- Category or tag base clash: a page with the same slug as your category base confuses rewrites. Rename one of them.
- Uploads 404: the file really is missing; check
wp-content/uploadsor re-run the migration of media. - WooCommerce product pages: go to Settings → Permalinks and check the Product permalinks base.
Plain permalinks as a test
Switch Settings → Permalinks to Plain temporarily. If posts load as /?p=123, WordPress itself is fine and the problem is only the rewrite rules. Switch back to Post name once fixed; plain links are bad for SEO.
Frequently asked questions
Will changing the permalink structure break my SEO?
Changing from one pretty structure to another changes every URL. WordPress redirects some old post URLs automatically, but not reliably. Add 301 redirects with a redirect plugin and update your sitemap in Google Search Console if you must change structure on an established site.
Does LiteSpeed support .htaccess?
Yes. LiteSpeed reads Apache-style .htaccess rewrite rules, so the standard WordPress block works on MdmHost without changes.
