WordPress 404 Error on Posts and Pages: Complete Fix Guide

You've published a blog post, shared the link everywhere — and then someone clicks it and gets this:

404 – Page Not Found

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.

What Is a 404 Error?

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 page genuinely doesn't exist at that URL
  • The page exists in your database, but WordPress can't route the request to it correctly

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:

  • All posts and pages return 404 except the homepage
  • Specific posts or pages return 404 after being published
  • 404 errors appear after migrating WordPress to a new server or domain
  • 404 errors appear after changing your permalink structure
  • Custom post types or category pages return 404
  • WordPress works locally but shows 404 on the live server

What Causes WordPress 404 Errors on Posts and Pages?

Understanding the root cause is half the battle. Here are the most common reasons WordPress posts and pages return 404 errors:

  • Permalink structure not saved or flushed — WordPress uses a system called "pretty permalinks" that relies on URL rewriting rules. If these rules aren't written to the .htaccess file, WordPress can't resolve post URLs.
  • Corrupted or missing .htaccess file — The .htaccess file contains the rewrite rules WordPress needs. If it's corrupted, missing, or overwritten, all post URLs break.
  • mod_rewrite not enabled on the server — Apache's mod_rewrite module is required for WordPress permalinks to work. If it's disabled on your server, you'll get 404 errors on every non-homepage URL.
  • Wrong WordPress Address or Site URL — If the URLs in Settings → General don't match your actual domain, WordPress generates broken links.
  • WordPress migrated to a new domain or subfolder — After a migration, old URLs may not resolve correctly if the database hasn't been updated to match the new domain.
  • Multisite configuration issues — On WordPress Multisite networks, 404 errors are common when the server isn't configured for multisite URL routing.
  • Plugin or theme conflict — Some plugins (especially SEO and redirect plugins) or themes register conflicting rewrite rules that break standard post URLs.
  • Custom post type rewrite rules not flushed — When a plugin registers a custom post type, WordPress needs to flush its rewrite rules. If this doesn't happen, custom post type URLs return 404.

How to Fix WordPress 404 Errors on Posts and Pages

02
Check and Fix the .htaccess File

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:

HTACCESS
# 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

  • If the file exists but has wrong content: replace its contents with the standard block above
  • If the file is missing entirely: create a new file named .htaccess in your WordPress root and paste in the standard block
  • If the file exists and looks correct: the issue is elsewhere — continue to the next fix

After editing, go to Settings → Permalinks and click Save Changes again to let WordPress write its rules fresh.

03
Check .htaccess File Permissions

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:

  1. Right-click the .htaccess file in your FTP client
  2. Select File Permissions (or Change Permissions)
  3. Enter 644 and click OK

To fix it via SSH:

BASH
chmod 644 /path/to/your/wordpress/.htaccess

Also check that the WordPress root folder itself has the correct permission:

BASH
chmod 755 /path/to/your/wordpress/
04
Enable mod_rewrite on Apache

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:

BASH
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:

BASH
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:

APACHE
<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.

05
Check WordPress Address and Site URL Settings

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:

  1. Go to Settings → General
  2. Check both the WordPress Address (URL) and Site Address (URL) fields
  3. Make sure both match your actual domain exactly — including https:// vs http:// and www vs non-www
  4. Click Save Changes

Common mismatches to look for:

  • http:// instead of https://
  • www.yourdomain.com vs yourdomain.com
  • A leftover staging or development URL (e.g., http://localhost or http://staging.yourdomain.com)

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:

PHP
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.

06
Fix 404 Errors After Migrating WordPress

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:

  1. Install and activate Better Search Replace from the WordPress plugin repository
  2. Go to Tools → Better Search Replace
  3. In the "Search for" field, enter your old URL (e.g., http://olddomain.com)
  4. In the "Replace with" field, enter your new URL (e.g., https://newdomain.com)
  5. Select all database tables
  6. Run a dry run first to preview changes
  7. Uncheck "Run as dry run?" and click Run Search/Replace to apply

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:

APACHE
RewriteBase /blog/
07
Deactivate All Plugins

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:

  1. Go to Plugins → Installed Plugins in wp-admin
  2. Select all plugins and choose Deactivate from Bulk Actions
  3. Visit the posts and pages that were returning 404 errors

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:

  • Yoast SEO (if permalink settings conflict)
  • All in One SEO Pack
  • WP Super Cache / W3 Total Cache (with wrong cache settings)
  • Custom permalink or redirect plugins
  • Membership and access-restriction plugins
08
Fix 404 on Custom Post Types

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:

PHP
'rewrite' => array('slug' => 'your-slug'),

And make sure the plugin is up to date.

09
Fix 404 Errors on WordPress Multisite

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:

HTACCESS
# 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.

10
Check for Conflicting Rewrite Rules in wp-config.php or functions.php

Occasionally, custom code added to wp-config.php or a theme's functions.php file can interfere with WordPress's routing.

  1. Connect via FTP and open functions.php from your active theme
  2. Look for any calls to add_rewrite_rule(), add_permastruct(), or flush_rewrite_rules()
  3. If you find any custom rewrite rules, comment them out temporarily and test

Also check wp-config.php for any non-standard URL or routing configurations.

Diagnosing 404 Errors: Useful Tools

These tools can help you investigate 404 errors more efficiently:

  • Query Monitor plugin — Shows you exactly which rewrite rules WordPress matched (or failed to match) for a given URL. Invaluable for diagnosing custom post type 404s.
  • Redirect Checker (online tool) — Paste your URL and see exactly what HTTP status code it returns and what redirect chain (if any) is happening.
  • Google Search Console — Under Coverage → Excluded, you'll find any pages Google has marked as 404. This helps you find 404s affecting your SEO that you might not have noticed manually.
  • Server error logs — Check your server's error log (accessible via cPanel or FTP) for 404 entries, which include the exact URL and timestamp.

Preventing WordPress 404 Errors

Once you've fixed the problem, here are steps to prevent it from happening again:

  • Always save permalinks after major changes. Any time you install a new plugin that uses custom post types, update WordPress, or make server changes, go to Settings → Permalinks and click Save Changes.
  • Use a redirect plugin for URL changes. If you change your permalink structure or rename a post's slug, old URLs will break. Use a plugin like Redirection or 301 Redirects to automatically forward old URLs to new ones.
  • Back up your .htaccess file. Before making any server changes, keep a copy of your working .htaccess file so you can restore it quickly.
  • Test after every migration. Whenever you move WordPress to a new server or domain, immediately test a variety of URLs — homepage, posts, pages, category archives, and custom post types.
  • Monitor 404s in Google Search Console. Connect your site to Google Search Console and regularly check the Coverage report for unexpected 404 errors that could be hurting your SEO.

Quick Reference: 404 Error Fix Summary

Scenario Fix
All posts/pages return 404Save permalinks via Settings → Permalinks
Happened after update or plugin changeSave permalinks, check .htaccess
.htaccess missing or corruptedRecreate with standard WordPress rules
Happens on Apache serverVerify mod_rewrite is enabled and AllowOverride is All
Wrong domain or URLFix WordPress Address and Site Address in Settings → General
After site migrationRun Better Search Replace to update URLs in database
Plugin causing conflictDeactivate all plugins, reactivate one by one
Only custom post types affectedFlush rewrite rules via Settings → Permalinks
WordPress MultisiteUpdate .htaccess with multisite-specific rewrite rules

Frequently Asked Questions

Q: My homepage works but all other pages show 404. What's wrong?
A: This is a classic permalink/rewrite rule issue. Go to Settings → Permalinks and click Save Changes first. If that doesn't work, check your .htaccess file and confirm mod_rewrite is enabled on your server.
Q: WordPress 404 errors are hurting my SEO. What should I do?
A: Fix the underlying cause first. Then submit an updated sitemap in Google Search Console and use the URL Inspection tool to request re-indexing of affected pages. Set up 301 redirects for any URLs that have permanently changed.
Q: I changed my permalink structure and now old links are broken. Can I fix this?
A: Yes. Install the Redirection plugin and set up 301 redirects from your old URL format to the new one. For example, redirect /?p=123 to /blog/my-post-title/. This also preserves your SEO ranking signals.
Q: Why do 404 errors appear after I move WordPress to a new server?
A: The new server may have a different configuration — mod_rewrite may be disabled, AllowOverride may not be set to All, or the .htaccess file may not have transferred correctly. Check all three.
Q: Can too many 404 errors hurt my Google ranking?
A: Soft 404s and broken internal links can hurt crawl efficiency and indirectly affect rankings. Fix genuine 404s promptly and set up proper 301 redirects for any URLs that have changed permanently.

Final Thoughts

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.
Views: 301