2

Upon migrating a WordPress site from development to production, I used Interconnectit's "Database Search and Replace Script in PHP" to update the site URL from http://dev.example.com to http://example.com

During the process, a script error popped up and I reloaded to do it again with false confidence. Now, http://example.com is pointing to http://dev.dev.example.com.

I tried to do seach/replace from http://dev.dev.example.com to http://example.com, but the string of http://dev.dev.example.com doesn't seem to exist.

If I access the site with a subdomain such as http://example.com/about, and can link to other subdomains such as http://example.com/contact.

  • Have you searched the database in phpMyAdmin or similar to see if the string exists and where? – Steve May 19 at 5:53
  • 1
    Just download the SQL locally, load it up in your favourite text editor and do a search and replace using that. – Simon Hayter May 19 at 13:40
  • "If I access the site with a subdomain such as http://example.com/about" - that's a subdirectory, not a subdomain. Is there supposed to be a question in your last sentence/paragraph? – MrWhite May 20 at 15:08
  • "Now, http://example.com is pointing to http://dev.dev.example.com" - What do you mean exactly by that? Do you see a 3xx redirect from example.com to dev.dev.example.com? If you do then is that a single redirect or multiple redirects? Do the internal links contain example.com or dev.dev.example.com? What was the "script error"? If you were replacing dev.example.com with example.com, it's difficult to imagine how you would end up with dev.dev.example.com - unless the process was run in reverse? – MrWhite May 20 at 15:14
1

Use the following SQL to find what your current system URL is in the database.

SELECT * FROM wp_options where option_name in ('home','siteurl'); from PHPMyAdmin in CPanel.

This should show you what the system currently thinks your siteurl and home are.

Next, make a backup of your database before making any further changes. You can do this via CPanel.

Next, follow the instructions in this article for fixing the URLs in wp_options, wp_posts, and wp_postmeta.

Rant: I'm not trying to rub this in your face, but I will say this for anyone who reads this in the future. Always make a copy of your database before making search/replace/update changes to your database. The typical end user DB tools don't have Undo capability so changes are permanent.

It's also a good idea to keep a development AND a production copy of your databases. I maintain both a production and development site so I can test changes in development before putting them into production. To keep dev current, I periodically copy production over to development just so it has the most up to date data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.