WordPress 404 error on every page (but not on the homepage)
Your homepage loads fine, but every post, page and category returns a 404.
The cause is almost always in the .htaccess file or the
permalinks. In 90% of cases, it’s fixed in under 5 minutes.
Published on · Updated on · 8 min read

Quick answer: This error occurs because the .htaccess file has lost WordPress’s rewrite rules, or because the permalinks are out of sync. The fastest fix is to go to Settings → Permalinks → Save changes. If that doesn’t fix it, you need to check or recreate the .htaccess. In most cases, it’s solved in under 5 minutes.
You open your site and the homepage works perfectly. But any post, page or category returns 404 Not Found. It’s not a random error: there’s a specific and very common cause.
Don’t worry: you haven’t lost content. Your database is intact. The problem is only URL routing. Let’s fix it.
What’s actually happening
WordPress doesn’t generate an HTML file for every post or page. All the
content lives in the database and is retrieved dynamically. For
a URL like /my-article/ to load the correct post,
the server uses the .htaccess file and its
rewrite rules.
When that file is missing, corrupted or has lost the WordPress rules, the server doesn’t know what to do with the URLs and responds directly with 404 Not Found.
Why does the homepage still work? Because it doesn’t need to go through that
process. When you visit the domain root, the server loads
index.php directly. The rest of the URLs do depend on the
.htaccess. That’s where the problem is.
In one sentence: WordPress knows what to show, but the server doesn’t know how to deliver it. That’s why the homepage works and the rest doesn’t.
The 5 most common causes
These are, in order of frequency, the reasons why this error appears:
The .htaccess has disappeared or is missing the rules
This is cause number one. A plugin has overwritten it, a migration
didn’t copy it properly or permissions prevent WordPress from writing to it.
When the BEGIN WordPress … END WordPress block isn’t
present, every URL fails except the homepage.
The permalinks haven’t been refreshed
After a migration, a domain change or a modification to the URL structure, the rules get out of sync. It’s usually fixed by re-saving the permalinks.
Server configuration: mod_rewrite or AllowOverride
Apache needs mod_rewrite enabled and
AllowOverride set to All. If they’re not,
the .htaccess is ignored. On Nginx there’s no
.htaccess: you need to check the
try_files directive.
Conflict between plugins that write to the .htaccess
Security, cache and SEO plugins write to the same file at the same time. When several do it, they can erase WordPress rules. If the error reappears every few days, that’s the cause.
Incorrect .htaccess permissions
If the file is read-only or has odd permissions, WordPress
can’t update it when saving the permalinks. The
correct permissions are 644 (or 444 if
you want to block writes).
How to fix it step by step
Follow this order: from the fastest and most frequent to the most complex. Step 1 resolves most cases.
Step 1 · Refresh the permalinks (90% success)
- Log into the WordPress dashboard.
- Go to Settings → Permalinks.
- Don’t change anything.
- Click «Save changes».
This regenerates the rules block inside the .htaccess.
Try opening any post. If it works, it’s fixed.
If it works but fails again in a few days, something
is overwriting the .htaccess. Jump to step 4.
Step 2 · Check and repair the .htaccess file
If step 1 didn’t work, connect via FTP or open the hosting
file manager, go to the WordPress root (where
wp-config.php is) and check the .htaccess.
Before touching anything, make a copy: download it or rename it
to .htaccess.bak.
If it doesn’t exist or is missing these lines, create or edit it with:
# 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 WordPress
Step 3 · Check the .htaccess permissions
The file should have 644 permissions. Some hostings recommend 444 to prevent plugins from overwriting it. Folders: 755. Files: 644. If they don’t match, change them and go back to step 1.
Step 4 · Rule out plugin conflicts
If the error persists or reappears, a plugin is overwriting the
.htaccess. The usual suspects:
- Security: Solid Security, Really Simple Security, Wordfence.
- Cache: W3 Total Cache, WP Rocket, LiteSpeed Cache.
- SEO plugins that modify the
.htaccess. - Multilingual: WPML, Polylang.
Deactivate all plugins and check whether the error disappears. If it does, reactivate them one by one until it fails again. The last one you activated is the culprit.
Step 5 · Confirm the server configuration
This requires contacting your hosting, because these are settings you can’t touch from WordPress:
- Apache: check that
mod_rewriteis enabled andAllowOverrideis set toAll. - Nginx: check that the
try_filesdirective redirects toindex.php.
Suggested message: «My WordPress returns 404 on every URL except
the homepage. I’ve already refreshed the permalinks and recreated the
.htaccess. Could you check whether mod_rewrite
is enabled and how AllowOverride is configured?»
Step 6 · Rule out malware in the .htaccess
If the problem reappears or the .htaccess contains rules you don’t
recognise, your site may be compromised. Malware modifies the
.htaccess frequently to inject redirects.
Scan with Wordfence or Sucuri. If there’s an infection, clean it before going any further with the file.
How to prevent it from happening again
Refresh the permalinks after every migration
Every time you move WordPress, change the domain or modify the URL structure, go to Settings → Permalinks and click «Save changes».
Limit the plugins that write to the .htaccess
If you have security + cache + SEO writing at the same time,
conflicts are inevitable. Keep the number of
tools that touch the .htaccess to a minimum.
WordPress-specialised hosting
Cheap hostings often limit mod_rewrite or
have problematic default configurations. A WordPress-specialised
hosting avoids many of these failures.
Complete backups before touching the .htaccess
Before modifying the .htaccess or changing the
server configuration, make sure you have an up-to-date
backup. If something goes wrong, you restore it in minutes.
Here are the most common HTTP errors and how to fix them, in case you want to complement this guide. And if your WordPress has other technical issues, also check the database connection error or the «Failed to write file to disk» error.
SEO tip: if the error has lasted several days, after fixing it resubmit the most important URLs from Google Search Console. You’ll speed up reindexing and reduce the impact on rankings.
Frequently asked questions
Why does the 404 error appear on every page but not on the homepage?
Because the homepage loads index.php directly,
while the rest of the URLs (posts, pages, categories)
depend on the .htaccess file to route the
request to WordPress. If the .htaccess is missing, is
corrupted or has lost the rewrite rules, the server
responds with 404 on every URL except the domain root.
How do you fix the 404 error on all WordPress pages?
The first step is to go to Settings → Permalinks
and click «Save changes» without modifying anything. This regenerates the
.htaccess rules and solves more than half of the
cases. If it doesn’t work, you need to check or recreate the
.htaccess with WordPress’s default rules,
check its permissions (644), rule out plugin conflicts and, as a
last resort, verify the server configuration
(mod_rewrite on Apache or try_files on
Nginx).
Do I lose my site content when this error appears?
No. The posts, pages, users and settings remain stored in
the database. The 404 error only affects URL
routing, not the data. As soon as the .htaccess rewrite
rules are corrected, all the content becomes
accessible again as normal.
What permissions should the .htaccess file have?
The usual value is 644 (read and write for the owner, read-only for the rest). Some hostings recommend 444 to prevent plugins from modifying it. WordPress needs to be able to write to it to update it automatically when saving the permalinks.
How do I know if the problem is the .htaccess or a plugin?
Start with Settings → Permalinks → Save
changes. If the problem is resolved instantly, it’s an
.htaccess problem. If it reappears within a
few days, a plugin is overwriting the file. In
that case, deactivate all plugins and reactivate them one by one
to identify the culprit.
Does this error affect my site’s SEO?
Yes, a lot. If Google receives 404 on all your posts and pages, it will progressively remove them from the index. Having a working homepage doesn’t compensate: a single URL can’t hold up the SEO of an entire site. The sooner you fix it, the better. If the error has lasted several days, it’s worth resubmitting the key URLs from Google Search Console to speed up reindexing.
Does your WordPress throw technical errors?
I review your installation, detect routing, permissions and configuration issues, and leave your site stable and ready to rank.