404 except homepage 📝 WordPress

WordPress: 404 Not Found on every page except the homepage (permalinks / .htaccess / Nginx rules)

Pretty permalinks aren’t being routed to index.php — .htaccess is missing/ignored (Apache) or Nginx lacks try_files.

Seen on: WordPress

Meaning

After migrations or server changes, the rewrite rules disappear. On Apache, AllowOverride None or mod_rewrite disabled ignores .htaccess; on Nginx, .htaccess never works and needs try_files.

Common causes

  • .htaccess missing or not writable
  • Apache AllowOverride None / mod_rewrite disabled
  • Nginx without try_files $uri $uri/ /index.php?$args
  • Site moved to a subfolder without updating RewriteBase

⚡ Quick fix

  1. Settings → Permalinks → Save (regenerates rules)
  2. Enable mod_rewrite and AllowOverride All
  3. Add try_files to the Nginx location block

Detailed fix by platform

Apache

  1. apache
    # .htaccess
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

Nginx

  1. nginx
    location / {
        try_files $uri $uri/ /index.php?$args;
    }

How to diagnose

  1. Server — Apache or Nginx?
  2. Rules — .htaccess / try_files present?
  3. Modules — mod_rewrite enabled?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.