You will have a few things to consider (later on the answer), I suggest the following steps:
Backup your Files and Database
This is pretty self-explanatory. You are going to do a lot of Data Manipulation, so be sure your original is safe.
Transfer your files
The fastest way to do this is to have a hoster where you can import directories from another server. This can be done by providing the FTP-details, as well as defining the targetdirectory.
As Servers have a internetconnection that is usually a lot faster than the one that users have, this is the preferable way to transfer the data. You can also use your command line to execute those commands by hand.
The slower option is to generate a ZIP-file, download, upload to your new server and decompress it. If you do not have the possibility of doing that, take the slow path - donloading everything and uploading everything. And go for coffee while the files transfer :)
Transfer your Database
Again, a lot of hosters have the option of importing an existing database into a new one, even from another server (of course, your old server has to accept external data connections).
If you can do this, great, but you can also export/import your database.
Set the new (Sub-)Domain to your new directory
On your new server, be sure your Files are set up the same way as on the old one, and point your subdomain to the same directory it did on the old server (usually the WordPress root)
Save the new
wp-config.php. You just have to edit the Database Connection details.
Load the new URL
WordPress should be set up by now, but it still uses the old SiteURL and AdminURL, so you won't be able to log in.
Change those Values in the
options-table in your new Database. The two Values you are looking for are
home. Place your new Domain there.
Check your Login and your Site
Now everything should work so far, you can login, edit and write, as well as use the site. The only Problem may be that your Posts still have the old URL for the images and attachments in them.
If your Posts contain the old URL, or if you are not sure, check your database in your
You can do this by searching your Database directly, or using a Script like Serial Search and Replace. If you find your old URL, you will have to replace it manually or automatically. I prefer doing it automatically and checking for errors afterwards.
Check the other tables
Also check if your other Tables contain the old URL. This may be a bit tricky to replace, but it also has to be done to move your site completely.
Regenerate your Permalinks
Just to be sure, save your Permalink Settings again to create the Permalinks again.
Check your site
Please, do not forget to REALLY check your site after you transferred it. Check all the functions, especially AJAX-stuff, Contactforms, Maps, etc. as they are more likely to fail than plain PHP/HTML.
Time for Beer :)
Things to watch out for!!
As always, nothing that was created manually, transferred manually and edited automatically is failproof. Here are a few commen traps that are easy to step into, but can also be avoided easily.
- Badly coded Plugins (Saving your Website URL instead of the relative Path and using the WordPress Functions to retrieve the full URL. There can also be a lot of Problems with your AjaxURL.)
- Encoding Problems (Be absolutely sure that you use the same encoding on both your Servers and Databases!!! Usually, if you go with the recommended UTF-8, this should be okay)
- Serialized Data (This is the biggest Problem you may encounter. If you use a Plugin like Tablepress, where an entire Table is stored in a serialized Array, it will break as soon as you automatically replace something. If you have Data like that, look for an export/import function in this specific Plugins, and use this as an extra step. If they do not have this function, you have to do it by hand)
- Server Settings (It can easily happen that your Site does not run on your new server due to standard settings. Be sure to have enough resources available!)
- Hardcoded URLs in your Theme (although this should not happen, it happens far too often and breaks your Images and Links as soon as the old site is not available anymore)
- Caching Problems (Do not use the same Caching Files as you did on your old server. The best way would be to deactivate the caching before exporting the site, as well as empty all cachings)
- Assuming everything works when you change the settings for the second time on your server (always check everything again)
- Options in your Plugins and Theme (Old Emailadresses etc.)
That should be it. It looks like a lot to do, but actually most of it runs automatically. You just have to think about everything that CAN go wrong, and check if it did :)