PreviewDNS Can Bork Your WordPress Install—But There’s a Fix

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.

image

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.

Manual Upgrades Are Not a Thing of the Past

image

What is it with certain webhosts? I mean, I know that none of the Fantastico-type installers have yet caught up to the fact that you can upgrade WordPress automatically from within the dashboard, so whenever you log into your control panel, it’s going to tell you that you need to upgrade even though you already did. (I found that “upgrading” through Cpanel when I have already upgraded is safe in BlueHost; I have not tried doing the equivalent with GoDaddy or DreamHost.)

But some web hosting companies seem determined to cut you off entirely from the automatic upgrade and install features of the latest versions of WordPress. And the absolute worst culprit I have yet discovered is Earthlink. Attempts at upgrading automatically not only don’t work, they manage to wipe out the active theme folder, much to the dismay of my client, who then needs me to go in, restore her theme, and handle the upgrade manually.

I have no idea why Earthlink sets it up this way, but the ability of WordPress to function rests on the existence of a file called Earthlink.dat, created when the Earthlink staff first installed WordPress. I’m not really interested in the technical details of why this problem exists, since I believe the best solution is for my client to switch web hosts. Their “starter site” plan costs more than twice what everyone else is charging, and I’m not hearing wonderful things about their service. (It was different back when my cousin Jason the Mac geek worked there.)

And this isn’t the only client whose WordPress site I’ve had to upgrade manually of late. In some cases, the installation was too old to upgrade automatically and wouldn’t work with the wonderful Instant Upgrade plugin. In others, there appeared to be some kind of permissions block. Either way, I’ve pretty much memorized the not-very-complicated instructions from the WordPress Codex.

Step 1: Replace WordPress files

  1. Get the latest WordPress. Either download and extract it to your computer or download it directly to the server.
  2. Delete your old wp-includes and wp-admin directories.
  3. Copy the new WordPress files to your server, overwriting old files in the root, except perhaps the wp-content folder (see “NOTE” below). Note that this means *all* the files, including all the files in the root directory as well. If you use the default or classic theme and have customized it, then you can skip that theme.

NOTE   The wp-content folder requires special handling, as do the plugins and themes folders. You should copy over the contents of these folders, not the entire folder. In some cases, copying the entire folder may overwrite all your customizations and added content.

Also take care to preserve the content of the wp-config.php file in the root directory. This file contains current settings for your existing installation, e.g. database sign-in information.

Step 2: Upgrade your installation

Visit your main WordPress admin page at /wp-admin. You may be asked to login again. If a database upgrade is necessary at this point, WordPress will detect it and give you a link to a URL like http://example.com/wordpress/wp-admin/upgrade.php. Follow that link and follow the instructions. This will update your database to be compatible with the latest code. If you fail to do this step, your blog might look funny.

This is not difficult, or even very time-consuming. It’s just tedious. And it shouldn’t be necessary.