Home » Blogging » Safely move WordPress blog to a new domain and update all existing links

Safely move WordPress blog to a new domain and update all existing links

I recently had to move WordPress blog from my old domain to my new domain (in other words my URL changed). I had a tough time updating all the existing links. Therefore, I decided to document the process in order to make future changes easy and to let other knows how I did it.

Changing the URL of the blog can have several detrimental effects. In my case, I lost traffic on my blog for a while. You also lose ranking on search results. But in my case the change had to be made. Anyway, without further delay, here are the steps:

Step 1: Backup You Databases and Files

Before I do any changes to my databases, I always back them up. On Ubuntu Server, this is what I do to backup my databases:


sudo su
cd /var/lib
sudo cp -a mysql mysql.bak

This will create a backup of all my databases into the folder mysql.bak. In case I screw up this is how I restore the backup:

sudo su
cd /var/lib
service mysql stop
rm -r mysql
mv mysql.bak mysql
service mysql start

Note the “sudo su” command is needed to gain access to the mysql folder.

Alternatively, you could use backup plugins such as Simple WordPress Backup or XCloner.

Now that the most important step is taken care of, let me proceed to explaining how actually I changed my WordPress blog URL.

Step 2: Install Search and Replace Plugin

The Search and Replace plugin allows you to search for and find strings in your database and replace the strings. You can search in ID, post-content, GUID, titel, excerpt, meta-data, comments, comment-author, comment-e-mail, comment-url, tags/categories and categories-description. It is possible to replace the user-ID in all tables and the user-login for more security in the WordPress-Application.

For convenience, you may use SSH / SFTP to install your plugin. The procedure to enable SSH / SFTP for WordPress is described in this post. After installation, you will find the plugin under “Tools”.

Search and Replace Plugin
Search and Replace Plugin

Step 3: Change URLs in WordPress General Settings

Go to WordPress General Settings and change the “WordPress Address (URL)” and “Site Address (URL)” to the domain name or URL you want and save the changes.

WordPress General Settings - URL
WordPress General Settings - URL

Now your WordPress URL/Domain Name should be changed and working. However, we are only half way through. In most cases the post URLs and the links will point to your old domain. Images may also not appear correctly. We will fix these in the next step.

Get 20% OFF with IPVanish VPN:

♦   Hide your browsing and streaming activity: No logs and no tracking
♦   Access geo-restricted content from anywhere
♦   Encrypt and anonymize: Kodi, Plex, Downloads, Personal Info
♦   Windows, Mac, Linux, Android, iOS, Router, and more.
♦   Money back guarantee - Sign Up Now

About the author


Anand is a self-learned computer enthusiast, a part-time blogger, and a Food Scientist by career. He has been blogging since 2010 on Linux, Ubuntu, Home/Media/File Servers, Smart Home Automation, and related HOW-TOs on htpcbeginner.com and smarthomebeginner.com.