A couple of weeks ago a client decided to move her website and blog from Earthlink, and there was much rejoicing. Earthlink is a terrible place to have a WordPress install. You have to do manual upgrades.
The new host, GoDaddy (not my first choice for hosting, in all honesty, though I have some of my own sites there; their servers are slow as treacle), offers a service called Preview DNS so you can make sure everything works on your new site before actually transferring the domain. This is a handy thing to be able to do and a nice thing for them to offer.
There’s only one problem, as I learned to my detriment. If you install WordPress under Preview DNS, the database is going to be really confused and totally bork your blog when you transfer the domain, because WordPress will be looking for http://www.mydomain.com.previewdns.com when it should be looking for http://www.mydomain.com. This means it won’t call your stylesheet properly and you can’t log in. Eeek!
The nice young man I talked to at GoDaddy hadn’t seen the problem before either, but some of the the other tech support staff there had. In fact, they’d actually put together a help file explaining how to solve the problem of unintentionally changing your WordPress URL.
Fixing it involves editing the MySQL database where WordPress stores all its information. It’s been a long time since I’ve done anything with a MySQL database besides back it up or restore it, but if you follow the directions exactly, you’ll be okay.
First you have to log into PHP MyAdmin. If you’ve forgotten the username and password for this, don’t worry. They’re contained in your wp-config.php file, and you can get to that through FTP. (Or I could, because I set the FTP up with the numerical IP address, not the previewdns.com address.)
Once inside phpMyAdmin, you’ll see a bunch of stuff that doesn’t mean much to you (if you’re like me and stay out of SQL databases). What you need is in the upper left-hand corner.
Click the white button that says SQL (the other one is for the help file) and enter the following code into the box that pops up, replacing the URLs as appropriate.
UPDATE wp_options
SET option_value = 'http://www.newlocation.com'
WHERE option_value = 'http://www.oldlocation.com'
Hit the “GO” button and you should be all set, at least in terms of things like being able to log in, and WordPress finding the theme’s stylesheet.
As it happened, however, there were a few internal links to other posts and other references to the dread “previewdns.com” link. So I needed to figure out how to fix those. This time, it was Lorelle Van Fossen who came to my rescue, with her “Search and Replace in WordPress MySQL Database” article from 2005. With Lorelle’s help, I was able to replace those lingering links in the body of the posts.
Now that I know this, I’ll be less hesitant to venture into my WordPress databases again if I need to—but honestly, I prefer not to need to. I’m sure this isn’t the last site relocation I’ll ever work on, though, so I’ll probably encounter Preview DNS again.