1. Home
  2. Technical Advice
  3. How to change the domain name of a WordPress website

How to change the domain name of a WordPress website

Do you want to change the domain name of your WordPress? This tutorial will show you how to change it easily using phpMyAdmin.

First step: Files and Database(s) backup

Before doing any modification to the actual database. we recommend you to make a backup of all your files and database(s) on your hosting.

Second step: Replace old website reference.

In those examples, we use ‘http://www.old-site.com’ as our current/old website, and 'http://www.new-site.com' as the new one we want to change

Every modification described within this tutorial will be made on the database.

The first command to use is:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-site.com', 'http://www.new-site.com') WHERE option_name = 'home' OR option_name = 'siteurl';

This command will change the old URL in the wp_options table.

Third step: Replace relative URL from posts.

This step consists of changing all the URL in the wp_post table.UPDATE wp_posts SET guid = replace(guid, 'http://www.old-site.com','http://www.new-site.com');

Fourth step: Replace URL from posts contents

Just to be sure every reference to your old URL doesn’t appear in any post content,

You must run this last command:UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-site.com','http://www.new-site.com');

Once all those modifications were done, you will able to use the new URL.

Be sure to clear your browser cache

Updated on 18 August 2021

Was this article helpful?

Related Articles