WordPress error

WordPress 404 Not Found on all pages except the home page after migration

The home page loads but every post and page returns 404, because the rewrite rules did not come across.

Checked 4 Nov 2026Official source linked
WordPress 404 Not Found on all pages except the home page after migration

The home page loads but every post and page returns 404, because the rewrite rules did not come across.

Why it happens

Pretty permalinks depend on rewrite rules in .htaccess on Apache. The file was not copied, was overwritten, or mod_rewrite is not enabled on the new server.

How to fix it

  1. 1

    Step 1

    Go to Settings > Permalinks and select Save Changes to regenerate the rules.

  2. 2

    Step 2

    If that fails, edit .htaccess in the site root and add the standard WordPress block.

  3. 3

    Step 3

    If it still fails, ask your host to enable mod_rewrite. On nginx, the rewrite rules go in the server configuration instead.

# 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

wp rewrite flush --hard

Source

Full guide: How to migrate a WordPress site to a new host without downtime →