WordPress is becoming ever more popular for publishing all kinds of websites. Solid stability, a plethora of useful (and some not so useful) plugins, an active developer community and a user-friendly interface are just some of the reasons that makes WordPress such a good publishing platform.
However, things can get a little tricky when moving a site from one domain to another. We decided to dish out some useful advice to ease your domain transition.
You need to copy the files AND the database. Your WordPress blog won’t work without your all-important database!
Firstly, copy the files from your hosting/server. Remember to copy the hidden files too. I use Filezilla. CPanel, FireFTP or one of the many FTP clients will do.
Second, copy your database. Go to phpMyAdmin (http://www.your-old-domain.com/phpmyadmin) and log in.
Select the database you want to copy.
Then click on the ‘export’ tab.
Here you have the export options. In the left field, click on ‘Select All’ to be sure you’ve got all the tables selected. Make sure you have the ‘SQL’ radio button selected.
Under ‘Structure’ click on ‘Add DROP TABLE…’
Don’t bother compressing the file, leave the ‘None’ radio button selected under ‘Compression’
Click on ‘Go’. This should activate an automatic download of your database, you need to save this on your hard drive.
Importing the WordPress blog to the new domain
The first thing to do is upload the files to the new root directory or a sub directory if that’s how you’re setting up the new website.
Now you need to import the database.
Go to phpMyAdmin (http://www.your-new-domain.com/phpmyadmin), log in.
Click on the ‘Import’ tab.
Click on ‘Browse’ and locate the backup of your blog’s database (the .sql file you downloaded earlier).
Click on ‘Go’.
Now you need to update the database in the ‘config.php’ file to match the new details. Do this with whichever editor you prefer.
Or so it would seem…
Chances are you’re going to need to update the URLs. If you’re using absolute paths in URL links instead of relative paths in URL link locations, some of the parameters are stored in the database. You’re going to need to run some queries to fix this or your site isn’t going to work.
In phpMyAdmin (http://www.your-new-domain.com/phpmyadmin), make sure you have the relevant database selected.
Click on the ‘SQL’ tab.
You need to update the WordPress options with the new blog location, type the following SQL command:
UPDATE wp_options SET option_value = replace(option_value, ‘http://olddomain.com’, ‘http://newdomain.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
Now you’re going to need to fix the URLs of the WordPress posts and pages, use the following SQL query:
UPDATE wp_posts SET guid = replace(guid, ‘http://your-old-domain.com’,’http://your-new-domain.com’);
If you’ve used absolute URLs to linked internally within blog posts or pages, the links will point to wrong locations after you move the blog to the new domain. Use the following SQL commands to fix these links (if you’re unsure its best to run this anyway):
UPDATE wp_posts SET post_content = replace(post_content, ‘http://your-old-domain.com’, ‘http://your-new-domain.com’);
You should now go to the blog on your new domain and navigate your way around the site to be sure everything is working properly.