If you’re wondering how to migrate a WordPress site, then the first stop you’ve probably tried already is the WordPress Codex. This is a very detailed guide that offers an effective migration solution, but it isn’t the easiest guide to follow if you’re a beginner to this process. At best it is a little confusing. At worst, you could lose all of your information.
The reason behind the migration doesn’t really matter. Whether you’re moving hosting accounts or you just need to migrate your root directory, this chore can be accomplished relatively easily and without the chances of a catastrophic mistake. Here’s what you’re going to need to do.
If You Need to Move a Subdirectory to a Root
The first thing you’ll want to do is backup your entire site. If something goes wrong during the migration, you don’t want to be left empty-handed. Make sure all of your plugins, themes, and your content database are included in the backup. This includes any media you may have.
There are several backup tools that can complete this process pretty effectively. Using a plugin that puts it in the Cloud is often the easiest. Copy your hidden files too.
If the root directory has an existing site, it must be deleted before you move the subdirectory. That might need to be backed up as well. Log into your php admin, drop the database, and then delete the WordPress files. You’ll also need to turn off Pretty Permalinks.
Now you’ll need to change your site address so it is the primary domain. Don’t refresh after this update. You’ll then download your index.php file and look for this bit of code: require (‘./wp-blog-header.php)
You’ll then replace it with this bit of code: require (‘./subdirectoryname/wp-blog-header.php). Save the file and then upload it to the root directory.
Now you’re ready to turn Pretty Permalinks back on and test your site.
If You Need to Move Between Hosts
After you’ve backed up your site, this project will require you to export your database. This can be found under your php admin. Use the quick option. Wait for the download to complete.
Once it has, you’ll be ready to create a new database on the server where you’re migrating your WordPress site. Make sure that you create a new user and add the new user to the new database with all privileges assigned. Make sure you get the name of the database down and remember your user name and password.
The next step is to edit the wp-config file. This php is in the WordPress install. Save the old one under a different file name locally as an easy backup. Then update the database name, user name, and passowrd within the file.
After this has been completed and saved, you’ll need to import the database. This is done through the php admin under the import command. Make sure that you don’t allow for the interruption of the import if a timeout should occur because the size of the file could be rather large.
Once the database has been imported, you’re ready to upload the site to your new host. Log into it through your FTP and then copy your files where you want them to be. The public HTML folder will put the files into the root directory. Make sure to keep your backup locally.
Now you’ll need to edit the database so all of your media and posts work properly. Don’t do this manually. Use a script to help you update everything so your php strings stay preserved. Scan your tables with a simple find/replace command and you’ll be good to go.
The final step is to configure your DNS settings. Go into your hosting account and make sure your domain is pointed toward the new host. Each hosting provider is a little different on how they make this work, so be sure to follow local instructions closely and carefully.
Remember that it may take up to 2 days for the changes to take hold. Once they have, you’ll be able to log into your site the same way you always did.
By following these steps, the process of migrating a WordPress site can be straightforward and relatively simple. Always make sure to keep a local backup, have one in the Cloud as well, and that way all of your bases are covered in case something goes wrong. That way you’ll be able to accomplish your migration goals as effectively as possible.