web hosting
build a website

Moving WordPress site to a new domain

Feb 9, 2014   //   by Anthony Devine   //   Website Development tips  //  No Comments

When moving a site from one domain to another, for example when you develop a site for somebody on your test server and then you move it over to their live server the best method to move that site over I have found is as follows.

First via FTP download all of the files to your computers desktop and then re-upload them to the new location on the new server. Backup the database from your server and move it over to the new server.

Change the wp-config.php file settings to the database details on the new server. Then in the wp-config.php file add in the following:

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
replacing the URL with your new domain name. This will force wordpress to use this new domain name instead of the one on your server.

You may find that the permalinks still do not work on your site. You have 2 options to get this to work, either open up the .htaccess file and change the links in there to the new location, or second solution is to delete the contents of the file and save it and make it writeable CHMOD777 then in the backend of your site go to Settings > Permalinks and then choose the option you want and save. This will then fix the links.

If you have hardcoded in all of the links to your test domain you can either go through all of your css files and other template files and change the links over or you can use the Velvet Blues Update URLs this plugin updates all of the links on your site without the hassle of finding them all.