After Migration From dev, Only my Links to the Homepage Still Redirect to dev
Question
I'm migrating one of my WordPress sites from a development version to the live version. The problem I'm having is with just the homepage links.
- the homepage link in the masthead is redirecting to the dev version.
- type the homepage URL into the browser, it redirects to dev.
- click the 'visit site' link in wp-admin, it redirects to dev.
The reasons might be because the migration didn't replace links in the database tables. And! Just to make it more interesting, my first migration failed. So, for a week I redirected the URL in cPanel to the dev version. I've since deleted this redirection, and every page is OK but home.
For a little context, lets say the live site URL is: http://x.tna.com
And the dev site is: http://dev.x.tna.com
. That's the same for the server directories: live.x
and dev.x
. I also used git so I have a repo git.x
. There are two databases, tna_x
and tna_x_dev
.
I've remade the entire migration, including:
- (on local using vim) verify all the links in the database (download to local, find and replace all URL subdomain instances of
dev.
with empty string) - (cPanel/subdomains) Deleted redirection to
dev.x.tna.com
. - (cPanel/Cache Settings) Disable cache for subdomain
x.tna.com
. - (WordPress Admin, Settings > General) Verify settings reflect the correct URL.
- (SSH) I searched in WordPress files,
grep -R dev
, and didn't find anything - (phpMyAdmin) I queried the database for
dev
, and didn't find anything. - (Wordpress Admin, Settings > Permalinks) Chnage permalink settings.
- (local browser) delete site cookies
All non-homepage links in x.tna.com
are fine. I also have access wp-admin
and add content and do other stuff.
Where is this setting hiding?
// Edit. I added #7 & #8; The .htaccess
file was unchanged, but I recreated to be sure. And I thought maybe it could be the browser, so I added #8
Solution
You most likely have invalid URLs in the database, however, it's also entirely possible to have a hard-coded URL in somewhere in the theme or perhaps a plugin, or even .htaccess
.
You could always search your entire database for the URL, and make adjustments manually. However, please note that if you make any adjustments to a URL within serialization, you should de-serialize it, make your adjustment, then re-serialize it again, before making the update in the database.
If you want a more automated approach to search and replace all occurrences of a string (A/K/A - replacing URLs), you should take a look at WP CLI.
To further troubleshoot...
- Disable all plugins.
- Make sure all drop-ins are removed for testing purposes.
- Verify there's no
cache
subdirectory in the directory./wp-content/
. - Verify contents of
.htaccess
in the root directory of WordPress. - Verify contents of
wp-config.php
file in the root directory of WordPress. - Clear browser temporary files and caches or just try another browser.