1. Home
  2. References
  3. Technical Advice
  4. 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 ‘https://www.old-site.com’ as our current/old website, and 'https://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, 'https://www.old-site.com', 'https://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, 'https://www.old-site.com','https://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, 'https://www.old-site.com','https://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 27 May 2022

Was this article helpful?

Related Articles