Fixing URL Redirects and Path Issues After a WordPress Migration
Content
Migrating a WordPress site with the 'All-in-One WP Migration and Backup' plugin is usually a smooth process, but a common frustration occurs when your new site redirects to the old URL or displays broken paths. This guide will explain why this happens and walk you through the most effective solutions to get your migrated site working correctly.
Why Do URL Redirects Happen After a Migration?
The core of this issue almost always lies in the database. During the export/import process, the plugin replaces all instances of the old site's URL with the new one. However, some references to the old URL can be missed or re-introduced. This can happen because of hardcoded URLs in theme files (like functions.php), settings in other plugins, or specific server configurations that override the database settings.
Step-by-Step Troubleshooting Guide
1. Verify and Update Database URLs (The Primary Fix)
The first and most crucial step is to ensure the home and siteurl values in your database are correct.
- Access your new site's database via phpMyAdmin (usually found in your hosting control panel).
- Locate the
wp_optionstable (the prefix may be different if you changed it). - Find the
option_namerows forhomeandsiteurl. - Confirm the
option_valuefor both is exactly your new site's URL (e.g.,https://yournewsite.com). - If they are incorrect, update them manually to the new URL.
2. Clear All Caches
Old data can be stubbornly held in various caches. After updating the database, clear all of them:
- WordPress Cache: If you use a caching plugin (e.g., W3 Total Cache, WP Super Cache), clear its cache from the plugin settings.
- Server Cache: Clear any server-level caching (e.g., Redis, Varnish). You may need to contact your hosting provider for this.
- Browser Cache: Clear your browser's cache and cookies or test the site in an incognito/private browser window.
3. Check for Hardcoded URLs in Your Theme
Some themes hardcode the site URL into the functions.php file. This will override any database settings.
- Navigate to Appearance > Theme Editor in your WordPress admin dashboard.
- Select your active theme and edit the
functions.phpfile. - Look for any lines containing your old URL (e.g.,
update_option('siteurl', 'http://old-site.com');ordefine('WP_HOME', 'http://old-site.com');). - Remove or comment out these lines, replacing the old URL with your new one if necessary.
4. Investigate Other Plugins
As seen in the sample threads, a custom or security plugin can sometimes cause conflicts that revert URLs. To test for this:
- Temporarily deactivate all plugins on your new site.
- Check if the redirection issue is resolved.
- If it is, reactivate your plugins one by one, checking the site after each activation, to identify the culprit.
5. Review Your .htaccess File
Incorrect rewrite rules in your .htaccess file can cause redirect loops or errors.
- Access your site's root directory via FTP or your host's file manager.
- Find and edit the
.htaccessfile. - The standard WordPress block should look similar to this. Ensure there are no odd redirect rules pointing to your old site.
# BEGIN WordPress
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]
# END WordPress
6. Update the Uploads Path
If you see errors about an invalid upload path, the full server path to your uploads directory might be incorrect.
- In your WordPress admin dashboard, go to Settings > Media.
- Look for the "Store uploads in this folder" option.
- It should typically be set to
wp-content/uploads. If it contains a full server path from your old host, change it back to the default value.
Final Checklist Before You Start
- DNS Propagation: If you've changed your domain's nameservers, wait for propagation to complete fully before testing. Alternatively, use a hosts file modification to preview the new site.
- Permalinks: After import, always go to Settings > Permalinks and simply click "Save Changes" twice to refresh the rewrite rules.
By methodically working through these steps, you can resolve the vast majority of post-migration URL issues. The problem is rarely with the 'All-in-One WP Migration and Backup' plugin itself but rather with lingering configuration data that needs to be cleaned up manually.
Related Support Threads Support
-
wp-login redirects to old websitehttps://wordpress.org/support/topic/wp-login-redirects-to-old-website/
-
restore/migration crisishttps://wordpress.org/support/topic/restore-migration-crisis/
-
Migrate from my pc harddrive to a demo site / temp sitehttps://wordpress.org/support/topic/migrate-from-my-pc-harddrive-to-a-demo-site-temp-site/
-
Unintended URL substitutionhttps://wordpress.org/support/topic/unintended-url-substitution/
-
How to migrate and upgrade WordPress version in my sitehttps://wordpress.org/support/topic/how-to-migrate-and-upgrade-wordpress-version-in-my-site/
-
Installing plugin on new host; conflict with URL. How to fix???https://wordpress.org/support/topic/installing-plugin-on-new-host-conflict-with-url-how-to-fix/
-
Site Migration with ‘Free Version’ of WPhttps://wordpress.org/support/topic/site-migration-with-free-version-of-wp/
-
Process to move to a new domain with all in one wp migrationhttps://wordpress.org/support/topic/process-to-move-to-a-new-domain-with-all-in-one-wp-migration/
-
Need to upgrade PHP version, server’s saying I have to start over completelyhttps://wordpress.org/support/topic/need-to-upgrade-php-version-servers-saying-i-have-to-start-over-completely/
-
DNS changes after migration – how to handle it?https://wordpress.org/support/topic/dns-changes-after-migration-how-to-handle-it/
-
Migration somehow points to old URLhttps://wordpress.org/support/topic/migration-somehow-points-to-old-url/
-
does deinstall ai1wp migration delete all db-entries in wp_options?https://wordpress.org/support/topic/does-deinstall-ai1wp-migration-delete-all-db-entries-in-wp_option/
-
Need I a blank wordpress installationhttps://wordpress.org/support/topic/need-i-a-blank-wordpress-installation/
-
wordpress.com to wordpress.orghttps://wordpress.org/support/topic/wordpress-com-to-wordpress-org-2/
-
Error: Too many redirectshttps://wordpress.org/support/topic/error-too-many-redirects-20/
-
Cannot set homepage after migrationhttps://wordpress.org/support/topic/cannot-set-homepage-after-migration/
-
Migrate to subfolderhttps://wordpress.org/support/topic/migrate-to-subfolder/
-
Newbie question: how to migratehttps://wordpress.org/support/topic/newbie-question-how-to-migrate/
-
Possible to migrate without wp on new host?https://wordpress.org/support/topic/possible-to-migrate-without-wp-on-new-host/
-
Home Page stuck on Hello Worldhttps://wordpress.org/support/topic/home-page-stuck-on-hello-world/
-
MIrgation form one server to anotherhttps://wordpress.org/support/topic/mirgation-form-one-server-to-another/
-
Migrating from Lightsail to EC2https://wordpress.org/support/topic/migrating-from-lightsail-to-ec2/
-
[NSFW] Urls extraviadas después de migrar wordpresshttps://wordpress.org/support/topic/urls-extraviadas-despues-de-migrar-wordpress/
-
All-in-one WP Migration Plugin-Successhttps://wordpress.org/support/topic/all-in-one-wp-migration-plugin-success/
-
Error: Your upload path is not valid or does not existhttps://wordpress.org/support/topic/error-your-upload-path-is-not-valid-or-does-not-exist/