5 Must-Follow Tips to Transfer a WordPress Site to a New Domain

transfer wordpress to new domain

One of the benefits of using WordPress as your content management system is that it’s so easy to transfer a WordPress site to a new domain when it comes time to move. Once you’ve made the decision to change domains, you don’t want to have to rebuild your whole site again on a new host.

However, it’s not so simple as merely copying files from one directory to another. If you forget about the database, for example, you could lose all of your site’s posts and comments.

The following steps will ensure that your WordPress migration goes as smoothly as possible.

1. Backup Your Database And Static Files

The first step is to download a backup copy of the database that holds all of your WordPress information. One method for this is to install a WordPress plugin that downloads all of the data for you. Another way is to perform the backup manually through a web hosting control panel like cPanel or phpMyAdmin, if your web hosting service gives you access to one.

With cPanel, you should use the “MySQL Databases” Partial Backup option. If using phpMyAdmin, login and navigate to your WordPress database. Select all the tables within and choose “Export” in the options menu. Use the “Quick” export method and the SQL format. Whichever process you use, keep the resultant file in a safe place.

Next, download all the files used in your site, starting from the root folder of your WordPress installation. Make sure you don’t miss any subfolders.

2. Set Up The New Database And Upload

Now you’ll integrate the downloaded files from the previous step into your new domain space. First, make a database and a new root user for it under the new domain.

Just like with downloading, you can upload the files through a WordPress plugin, of which there are several to choose from. In this case you will have to make a fresh installation of WorPpress on the new domain, install the plugin, and then use that plugin to upload the database backup that you saved from your old site.

Of course, you can also do this manually through cPanel or phpMyAdmin. Navigate to the new database and select the “Import” tab. You’ll be given the option to populate the database from a file on your computer. Choose the database backup file that you saved earlier.

With either above methods, make sure to update the wp_options table with your site’s new URL using phpMyAdmin.

After updating the new database, you can upload the static files from your site using a standard FTP program. If you used the WordPress plugin method above, be careful to overwrite all files with your own.

3. Update Your Configuration File And Settings

The wp_config.php file in your WordPress install will need to be updated to reflect the new database and user that WordPress will be using. Simply open the file in a text editor and change the old values for the database name, user and password to the new ones. You should also login to WordPress and make sure all the settings are still correct.

4. Redirect From The Old Domain To The New One

It’s important to help any visitors to your site find their way to the new domain. It’s just a matter of editing the .htaccess file in your old domain. If you’re keeping the URL structure exactly the same, then you can simply 301 redirect the entire old site to the new one, like so (substitute your old and new domain names for the example ones):

RewriteEngine on

RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR]

RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC]

RewriteRule ^(.*)$ http://newdomain.net/$1 [L,R=301,NC]

Otherwise, you’ll need to add a 301 redirect rule for every url that’s changing, as in this example line:

Redirect 301 /old.html http://www.newdomain.com/new.html

That’s a lot of work, so try not to make changes to your site structure unless absolutely necessary.

5. Fixing Link Rot

When you first add a post to your site, every included link should work perfectly. But as time goes by and pages get taken down or change locations, a phenomenon knows as link rot can occur, by which a link becomes invalid or outdated. In the span of a single year up to 10% of the links on an average blog post can suffer from link rot. Additionally, because of your recent domain name change, many internal links on your site will no longer work or will go through a needless redirect.

Changing over to a new domain presents a great opportunity to go through old posts and fix broken, outdated links. For internal links, you won’t even have to do it by hand, as there are WordPress plugins that will automatically change all old domain links to the new one.

Conclusion

Now that you know how to transfer WordPress site to a new domain, there’s no reason to put off your next migration. Make sure to follow all steps carefully and keep notes for yourself in case it must be done over multiple sessions. But given how quick the process can be, you can get it done in the space of an afternoon, just in time for a celebratory toast in the evening.