You’ve got a WordPress site, and you’ve had to change the domain name where it’s hosted. Suddenly none of the links on the site work. How do you fix it?
Well, you’ve got some manual database updates ahead of you. WordPress comes with a MySQL database. You’ll need to log in and run a few SQL statements to make the necessary changes.
Don’t worry if you don’t know the login information for your WordPress site’s database. That information can be found in one of the WordPress source files, which can be found at:
<wordpress-dir>/wp-config.php
Armed with this information, you can login and (carefully) make the necessary changes. You should seriously consider backing up the database before you make any changes. See my earlier article on doing MySQL database dumps.
OK. First, we’ll need to change two settings in the WP_OPTIONS table, “siteurl” and “home”:
UPDATE wp_options SET option_value = 'http://yourdomain.com' WHERE option_name = 'siteurl'; UPDATE wp_options SET option_value = 'http://yourdomain.com' WHERE option_name = 'home';
Next, there is the WP_POSTS table. The “guid” column of this table lists the full URL of a revision of a post. There can be a lot of rows in this table, and every row needs to have the domain name portion of its “guid” updated.
It’s tedious, but doable.
By updating these two settings in the WP_OPTIONS table and the URL’s in the WP_POSTS table, you can successfully move your WordPress site to a different domain name.
Well, this was in 2011. Since then, other less manual mechanisms have been developed. There’s an export/import feature that allows you to export the content of a WordPress site and import it into an empty WordPress site, which takes care of most of the drudgery of moving your site.
Simply create your new WordPress app at your new domain. Export the one from the old domain. and then import it.