WordPress Pages Returning 404 (Permalink Issue)

Warning Frequency: Common
Error message: 404 Not Found — page exists but returns 404

One of the most common WordPress issues: your pages and posts exist in the database, but visiting them returns a 404 Not Found error. Only the homepage works. This is almost always a permalink/rewrite rule issue.

WordPress uses URL rewriting to create pretty permalinks (e.g., /my-post/ instead of ?p=123). If the rewrite rules are missing or corrupted, the web server can’t route requests to WordPress, and you get 404s.

Common Causes

  1. Corrupted or missing .htaccess file (Apache)
  2. nginx missing try_files directive for WordPress
  3. Rewrite rules need flushing after migration or plugin change
  4. mod_rewrite not enabled on Apache
  5. Custom post type rewrite rules not flushed after plugin activation

How to Fix It

  1. Flush permalinks: Go to Settings > Permalinks, don't change anything, just click Save Changes
  2. Check .htaccess: Make sure it contains the standard WordPress rewrite rules (Settings > Permalinks will regenerate them)
  3. For nginx: Add try_files $uri $uri/ /index.php?$args; in your server block
  4. For Apache: Ensure mod_rewrite is enabled: sudo a2enmod rewrite && sudo systemctl restart apache2
  5. For custom post types: Run wp rewrite flush via WP-CLI after activating CPT plugins

Frequently Asked Questions

Why do my WordPress pages show 404 when they exist?
This is a permalink/rewrite rule issue. Go to Settings > Permalinks and click Save Changes to regenerate the rewrite rules. This fixes it 90% of the time.
My .htaccess keeps getting overwritten. What should I do?
A plugin or your server config might be overwriting it. Make sure .htaccess is writable (644) and check if a security or caching plugin is modifying it.
Get WordPress Performance Tips

Plugin reviews, speed optimization guides, and error debugging — straight to your inbox.

No spam. Unsubscribe anytime. We respect your privacy.