wordpress

how to fix wordpress when changing the site url breaks your site

I first went online in 1995 and have posting things online ever since, first on a personal website (with a tilde in the url!) on my internet provider’s domain and then a blog in 1999 on the now-defunct cheesedip.com (runnning first on Blogger and then Movable Type) and then from 2002 on the now-defunct lliiaa.com (Movable Type). So I’ve got two and a half decades of using blogging software personally—plusa handful of years of both front and back backend work on Movable Type and WordPress sites professionally—and I can’t honestly remember the last time I was as fucking annoyed to have a super basic option a CMS go wrong and be unfixable for no apparent reason as I was last night, when I changed this site’s site url in the process of going live and then had it just not work no matter what. Even going in through phpMyAdmin to edit the database directly didn’t work and I was ready to tear hair out (not mine, but that of WordPress engineers cause something this simple really should just work).

If you’ve arrived here because you did the same thing, you probably already have at least a few other tabs open from the same search that brought you here. I tried all those things, none of them worked for me and they were also all kinda time consuming besides. Here’s what I ended up doing which is also what I think is the most elegant solution to the problem as long as you have access to phpMyAdmin through your hosting provider.

  1. Go to Tools -> Export, and then export your content. I only needed to export posts, but choose the combination that makes sense for your site.
  2. Open your copy of wp-config.php and note the values it saved during your installation process for the following variables: db_name, db_user, db_password, db_host
  3. Using phpMyAdmin, access your WP install and click on your db_name in the panel on the left, so the tables listed underneath it appear on the right.
  4. Select all twelve tables; underneath them there will should be a drop-down with a handful of options. Select drop and on the next page, you’ll be asked “do you really want to execute the following query?” If you say yes, you’ll be wiping your current WP database—but that’s what we want, and we backed up your content in the first step, so say yes. And now we’re done with phpMyAdmin.
  5. I moved my WP install so it now lives in the same root folder as this blog, but YMMV. Wherever is, access wp-login.php through your browser and reinstall your blog with the values you saved from wp-config.php in our second step.
  6. Go to Tools -> Import, and then import the content we exported in step one.

Et voilà, you should now have a working blog at the url of your choice again. Which you should’ve had all along, but hey, WordPress!

Thanks to Matt Haughey for inspiring me to write this post by always putting together tutorials to save people from having to problem solve things he’s already thoroughly researched and fixed!

p.s. If you found this useful,