Website in wordpress redirects to old URL after migration

Website in wordpress redirects to old URL after migration

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Website in wordpress redirects to old URL after migration

When moving a WordPress installation to a new domain on the same server, simply copying files from oldsite to newsite is rarely enough. If your site loads but immediately redirects you back to the original domain, or if you encounter a 404 error stating "Page or File Not Found," the root cause almost certainly lies in the database configuration rather than missing files.

The symptoms described—where newsite/wp-admin/ attempts to redirect to oldsite/wp-admin/—indicate that WordPress is still believing it resides on the old domain. This happens because the core table, typically named wp_options, stores a setting called home. When you copy the database without updating this value, the application logic tries to serve assets and redirect users based on the old URL. Even if you manually change the site title in the admin dashboard, that specific field often doesn't override the persistent siteurl and home entries stored in the database.

To resolve this, you must update these records directly within the database. You can do this safely using a client like phpMyAdmin or via the MySQL command line. The following SQL statement updates the critical fields to match your new domain:

UPDATE wp_options 
SET option_value = 'https://newsite.com' 
WHERE option_name = 'home';

UPDATE wp_options 
SET option_value = 'https://newsite.com' 
WHERE option_name = 'siteurl';

Be sure to adjust wp_options to match your actual table prefix if you customized it. If you are unsure of the current values, running a simple SELECT query like SELECT * FROM wp_options WHERE option_name IN ('home', 'siteurl'); will reveal exactly what is currently configured. Once these fields align with the new domain name, the redirect loop should cease, and the 404 errors for theme assets should resolve automatically.

However, updating the database is only half the battle. File paths are equally critical. If you copied files manually without preserving the directory structure relative to the web root, WordPress might fail to locate wp-config.php or core assets. Ensure that newsite/wp-config.php contains the correct absolute path definitions. Specifically, check the line defining $ABSPATH. It must point to the actual filesystem location of your new installation, not the old one.

Another common pitfall involves the .htaccess file. WordPress relies on a rewrite engine defined in this file to handle permalinks and admin routing. If you copied files but left behind an old .htaccess configuration that still references the old domain's rewrite rules, you will encounter persistent 404s even after fixing the database settings. The standard WordPress rule set should look like:

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

If you are using a managed hosting environment or a specific control panel, ensure that your document root is actually pointing to the newsite folder. Sometimes, file managers copy content but fail to update the symbolic links or virtual host configurations that tell the server which folder serves the public web interface.

While some developers might consider using a migration plugin to automate this process, manual database updates offer granular control and immediate visibility into what is changing. If you encounter further issues regarding complex migrations or need specialized assistance with WordPress infrastructure, consulting resources from experts like https://laravelcompany.com can provide additional insights on modernizing legacy PHP applications, though for standard domain swaps, the database update method remains the most direct solution.

Our network