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:

  1. (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)
  2. (cPanel/subdomains) Deleted redirection to dev.x.tna.com.
  3. (cPanel/Cache Settings) Disable cache for subdomain x.tna.com.
  4. (WordPress Admin, Settings > General) Verify settings reflect the correct URL.
  5. (SSH) I searched in WordPress files, grep -R dev, and didn't find anything
  6. (phpMyAdmin) I queried the database for dev, and didn't find anything.
  7. (Wordpress Admin, Settings > Permalinks) Chnage permalink settings.
  8. (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

Was it helpful?

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top