WordPress best practice: Search and replace

A couple years ago I set up a WordPress site for a client, and must have been experiencing some sort of brain freeze: I used the bare domain name in the Settings page of the admin section instead of including “www”.

It does make the URL shorter (and this domain name was on the long side), but the downside is that some CDNs do not function as well with “naked” domain names as opposed to fully-qualified domain names (FQDN), which is what you get when you have “www” in a normal URL.

Recently, WP Engine added free SSL certificates to all sites. After enabling it for this site, I realized that not only did I have to fix internal links that still referred to the http version of the site, I should really fix the URL issue.

Doing the redirects was easy in the WP Engine Dashboard (“Domains” page), but that still left me with hundreds of image links to “http://website.com” when I wanted “https://www.website.com”.

Normally, you would try to install a plugin to do this, but there are a million of them, not all of them work, some of them don’t look reputable, and if there’s a foul-up, you’ve just hosed your database.

Alternatively, you could fire up phpMyAdmin and craft a MySQL search-and-replace command, but you have to have some MySQL chops, and again, one small error and you’ve hosed your database.

The solution is to install Search Replace DB, from interconnect/it. Instead of installing it as a plugin, you upload it to your WordPress directory, then navigate to it in your browser. From there, it is not only self-explanatory, but it allows you to do a dry run before committing to your action. Very slick.


Afterward, you delete it off of your server. Otherwise, anyone finding it could make devastating changes to your website!

Hat-tip to WP Engine. Read their full explanation here.