You've published a blog post, shared the link everywhere — and then someone clicks it and gets this:
Or maybe your entire site is working fine, but every single post and page returns a 404 error. Or perhaps it only started happening after a WordPress update, a server migration, or a permalink change.
Whatever the scenario, a WordPress 404 error on posts and pages is one of the most common — and most misunderstood — problems WordPress site owners face. The frustrating part is that your content is usually still there. WordPress just can't find it.
In this complete guide, we'll explain exactly why this happens and walk you through every proven fix to resolve it.
A 404 error is an HTTP status code that means the server could not find the requested page. When a visitor tries to open a URL on your WordPress site and gets a 404, it means one of two things:
The second scenario is far more common in WordPress — and it's almost always caused by a permalink or .htaccess issue, not missing content.
You might encounter WordPress 404 errors in the following situations:
Understanding the root cause is half the battle. Here are the most common reasons WordPress posts and pages return 404 errors:
This single step fixes the overwhelming majority of WordPress 404 errors on posts and pages. It forces WordPress to regenerate all rewrite rules and rewrite the .htaccess file.
That's it. WordPress will flush the rewrite rules and write a fresh set to your .htaccess file.
If your 404 error appeared after any of the following, this fix almost always resolves it:
If the 404 errors persist after saving permalinks, continue to the fixes below.
If regenerating permalinks didn't work, the .htaccess file itself may be corrupted, have incorrect permissions, or be missing entirely.
Step 1: Locate the .htaccess file
Connect to your server via FTP or your hosting file manager and navigate to your WordPress root directory (the same folder that contains wp-config.php).
The .htaccess file is hidden by default. In FileZilla: go to Server → Force showing hidden files. In cPanel File Manager: click Settings and enable "Show Hidden Files."
Step 2: Check its contents
Open the .htaccess file. A standard WordPress .htaccess file should contain the following block:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
If the file is empty, missing these rules, or contains something different, that's your problem.
Step 3: Fix the .htaccess file
After editing, go to Settings → Permalinks and click Save Changes again to let WordPress write its rules fresh.
Even if the .htaccess file has the correct content, wrong file permissions can prevent the server from reading it — causing 404 errors.
Correct .htaccess permission: 644
To fix it via FTP:
644 and click OKTo fix it via SSH:
chmod 644 /path/to/your/wordpress/.htaccess
Also check that the WordPress root folder itself has the correct permission:
chmod 755 /path/to/your/wordpress/
WordPress permalink URLs rely on Apache's mod_rewrite module to redirect requests through index.php. If this module is disabled on your server, no amount of .htaccess editing will fix the 404 errors.
Check if mod_rewrite is enabled:
If you have SSH access, run:
apache2ctl -M | grep rewrite
If you see rewrite_module in the output, it's enabled. If you don't see it, it needs to be activated.
Enable mod_rewrite:
On Ubuntu/Debian servers:
sudo a2enmod rewrite
sudo systemctl restart apache2
On cPanel hosting, this is usually enabled by default — if it's not, contact your hosting provider and ask them to enable mod_rewrite.
Check your Apache VirtualHost configuration:
Even if mod_rewrite is enabled, it won't work unless your VirtualHost configuration allows .htaccess overrides. The AllowOverride directive must be set to All:
<Directory /var/www/html/your-wordpress-site/>
AllowOverride All
</Directory>
If this is set to None or FileInfo, .htaccess rules are ignored and your permalinks will break. Ask your hosting provider to check and update this setting if needed.
If your WordPress Address (URL) or Site Address (URL) settings don't match your actual domain, WordPress will generate incorrect links and your posts may return 404 errors.
Via WordPress admin:
https:// vs http:// and www vs non-wwwCommon mismatches to look for:
If you can't access wp-admin:
Edit wp-config.php directly via FTP and add these two lines just before the /* That's all, stop editing! */ comment:
define('WP_HOME', 'https://yourdomain.com');
define('WP_SITEURL', 'https://yourdomain.com');
Replace https://yourdomain.com with your actual domain. Save the file and reload your site.
If your 404 errors appeared after moving WordPress to a new domain, subdomain, or subfolder, the URLs stored in your WordPress database may still point to the old location.
Update URLs in the database:
The safest way to do this is with the Better Search Replace plugin:
After updating the database, go to Settings → Permalinks and click Save Changes again.
If you moved WordPress to a subfolder or subdirectory:
For example, if your site now lives at yourdomain.com/blog/ instead of yourdomain.com/, you'll need to update both the database URLs and the .htaccess file's RewriteBase setting:
RewriteBase /blog/
Some plugins — particularly SEO plugins, redirect managers, and membership plugins — register their own rewrite rules. A conflict between these rules and WordPress's default routing can cause 404 errors on posts and pages.
To test if a plugin is the cause:
If they load correctly now, reactivate plugins one by one, checking after each, until the 404 errors return. The last plugin you activated is the conflict.
Common plugins that can cause 404 issues include:
If you're seeing 404 errors only on a specific custom post type (like portfolio, products, team members, etc.) but regular posts and pages work fine, the issue is almost always unflushed rewrite rules.
Quick fix: flush rewrite rules
Go to Settings → Permalinks and click Save Changes — this flushes all rewrite rules including custom post types.
If that doesn't work, the plugin or theme registering the custom post type may have a bug in how it sets up the rewrite slug. Check that the register_post_type() call includes:
'rewrite' => array('slug' => 'your-slug'),
And make sure the plugin is up to date.
On a WordPress Multisite network, 404 errors are common and usually relate to server configuration rather than WordPress settings.
For subdirectory multisite (e.g., yourdomain.com/site2/):
Your .htaccess file needs specific multisite rewrite rules. Replace the standard WordPress .htaccess block with this:
# BEGIN WordPress Multisite
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# Add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# END WordPress Multisite
For subdomain multisite (e.g., site2.yourdomain.com):
Your server needs wildcard subdomain support. Contact your hosting provider to enable wildcard DNS and wildcard SSL if not already configured.
Occasionally, custom code added to wp-config.php or a theme's functions.php file can interfere with WordPress's routing.
functions.php from your active themeadd_rewrite_rule(), add_permastruct(), or flush_rewrite_rules()Also check wp-config.php for any non-standard URL or routing configurations.
These tools can help you investigate 404 errors more efficiently:
Once you've fixed the problem, here are steps to prevent it from happening again:
| Scenario | Fix |
|---|---|
| All posts/pages return 404 | Save permalinks via Settings → Permalinks |
| Happened after update or plugin change | Save permalinks, check .htaccess |
| .htaccess missing or corrupted | Recreate with standard WordPress rules |
| Happens on Apache server | Verify mod_rewrite is enabled and AllowOverride is All |
| Wrong domain or URL | Fix WordPress Address and Site Address in Settings → General |
| After site migration | Run Better Search Replace to update URLs in database |
| Plugin causing conflict | Deactivate all plugins, reactivate one by one |
| Only custom post types affected | Flush rewrite rules via Settings → Permalinks |
| WordPress Multisite | Update .htaccess with multisite-specific rewrite rules |
/?p=123 to /blog/my-post-title/. This also preserves your SEO ranking signals.
The WordPress 404 error on posts and pages almost always has a simple root cause — and in the vast majority of cases, clicking Save Changes on the Permalinks settings page is all it takes to fix it. For more persistent cases, a few minutes with your .htaccess file will usually do the trick.
If your 404 errors are more complex — after a migration, on a Multisite network, or involving custom post types — the additional fixes in this guide will walk you through every scenario.
Still stuck? Our team of WordPress developers has solved every variation of the 404 problem imaginable. Get in touch with us and we'll diagnose and fix the issue for you.
Contact us today and we'll get your site back online — fast.