Ffile2fix
Sign in Get started

How to fix 404 Not Found on every page after migrating a site

Not Found. The requested URL was not found on this server.

When only the homepage loads after a migration, the new server is not rewriting pretty URLs to index.php, so it looks for a real folder like /about/ and finds nothing. The content is usually fine; the routing layer did not come across with it.

Also appears as: 404 Not Found nginx (every page except the homepage) · Page not found on all posts after moving WordPress to a new host · Not Found: The requested URL /about/ was not found on this server. Apache/2.4 Server at example.com Port 443 · Laravel routes return 404 after migration, only / works

Common causes

  • The hidden .htaccess file was not copied because the FTP client or archive skipped dotfiles
  • mod_rewrite is disabled or AllowOverride None is set, so Apache ignores .htaccess
  • The new server runs Nginx or OpenLiteSpeed with no try_files rule for the front controller
  • Document root points to the wrong folder, such as public_html instead of public/ for Laravel
  • Moving from Windows/macOS to Linux exposed filename case mismatches (Image.JPG vs image.jpg)
  • Old domain or subfolder still stored in the database, so links point to paths that do not exist

How to fix it

  1. Check that .htaccess exists. Enable "show hidden files" in File Manager or your FTP client and confirm .htaccess is in the site root. For WordPress, saving Settings > Permalinks regenerates it if the folder is writable.
  2. Confirm rewrites are allowed (Apache). On a VPS run sudo a2enmod rewrite and set AllowOverride All (or FileInfo) for the site directory, then restart Apache. Shared hosts normally have this on already.
  3. Add a front-controller rule (Nginx). Nginx ignores .htaccess. Add try_files $uri $uri/ /index.php?$args; to the location / block, run sudo nginx -t and reload.
  4. Verify the document root. Make sure the domain points to the folder holding index.php. Laravel and Symfony apps must point to public/; a subfolder install may need RewriteBase adjusted.
  5. Update URLs in the database. If links still use the old domain or path, run a serialization-safe search and replace (WP-CLI wp search-replace or a dump tool) instead of a plain SQL REPLACE.
  6. Check filename case. Linux file systems are case-sensitive. Rename files or fix references so the case matches exactly, especially images and includes.

.htaccess (standard WordPress rules)

# 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

How to stop it happening again

  • Migrate with a full archive (tar or ZIP) that includes dotfiles, then verify .htaccess
  • Check the target server type (Apache, Nginx, LiteSpeed) before moving
  • Run a link check right after DNS switches

Frequently asked questions

Why does the homepage work but nothing else?

The homepage maps directly to index.php, so it loads without rewriting. Every other pretty URL needs a rewrite rule to reach index.php, and that rule is missing or ignored.

Can I just switch permalinks to Plain?

It proves the diagnosis, since ?p=123 URLs work without rewrites, but it changes every URL and harms SEO. Fix the rewrite rules and switch back.

Do I need .htaccess on an Nginx server?

No, Nginx never reads it. The equivalent rules go in the server block, which on managed hosting is usually set by the host or a control panel option.