How to change domain name for a WordPress website (5 ways)

Want to change the domain name for your WordPress website? No problem, in this guide We’ll walk you through 5 different methods to change the domain name for a WordPress website from cPanel PHPMyAdmin.

Before following this guide make sure you’ve down the following:

  • registered the desired domain name and pointed it towards your hosting package
  • added it on your cPanel account as Addon domain

Change domain name from wp-admin dashboard

Go to your wp-admin dashboard and under Settins change the domain name for the following fields:

  • WordPress Address (URL)
  • Site Address (URL)

Make sure to double-check the domain name and click on Save Changes afterward.

To add a domain name to cPanel, got to Addon Domains.

If the domain name is already added, simply change the Document root for it to point it to the already existing installation of WordPress.

Click on the pencil icon next to the Document root path to change it.

After changing the path click on the Change button to save new path.

Change domain name using a plugin

One of the most popular plugins to change a domain name in WordPress is Search & Replace.

To install this plugin head over to Plugins > Add New.

Search for “search replace” and install then activate the plugin:

To access the plugin Search & Replace go to Tools > Search & Replace

Before changing the domain name I recommend making a database backup (export) from the Backup Database page by clicking on the Create SQL File button.

Afterward on the page Replace Domain URL in the field Search for: put the current domain name and in the field Replace with: put the new doamin name. You can also use URL with http:// or https:// prefix.

And finally click on the Do Replace Domain/URL button.

The plugin will search and replace the old domain name with the new one in the entire database. After it’s finished you can start using the new domain to enter wp-admin dashboard.

Change domain name directly from the database (PHPMyAdmin)

First to identify your database, open the wp-config.php file and under DB_NAME check the name of the database that your WordPress website is using.

From cPanelnavigate to PHPMyAdmin.

After PHPMyAdmin loads up on the left side of the screen, you will see a list of all databases, make sure to select the database name as written in your wp-config.php file.

You will see a list of all the tables in this database. Find the table wp_options – the prefix for this table is also defined in the wp-config.php file under table_prefix.

Click the pencil icon Edit before values siteurl and home – then change the domain name.

Under option_value change the domain name and when you are done click on the Go button at the bottom of the page.

Do the same for the home option as well.

NOTE: After changing the domain name directly in the database it’s important to log into wp-admin dashboard under the new domain name and underSetting > permalinks click on the Save Changes button to regenerate all links in the database.

Change domain name from functions.php file

In this advanced method, we will use the built-in update_option function to change a domain name for a WordPress website. By using this function we will rewrite the site_url and home settings in the database.

After adding the following code inside your active theme’s functions.php file, access the website using the new domain name, to make sure everything is working as expected, and then make sure to delete the code from the functions.php file.

Open your functions.php file (I suggest making a Child theme first) and add the following code right under the first line with<?php


The beginning of the file should look like this:

After making changes make sure to click on the Save Changes button in the top right corner.

After saving changes, access the website under the new domain name and change back the functions.php file as it was – delete the above added lines.

Change domain name from wp-config.php file

Similar like the previous method, we will edit one of WordPress’s main config files – wp-config.php and in it set new values for site_url and home settings.

Open wp-config.php file and add the following code at the beginning just after <?php

define('WP_HOME', '');
define('WP_SITEURL', '');

The beginning of the file should look like this:

After making changes make sure to click on the Save Changes button in the top right corner.

NOTE: By using this method we are overwriting the domain name in WordPress, and you won’t be able to change it from the wp-admin dashboard until you remove these lines from the wp-config.php file.


To change a domain name for a WordPress website we need to do several things:

  • Register a new domain name
  • Point it to your hosting using nameservers
  • Set the Root Directory towards the WordPress files
  • Change site address in the database

As always, before making any changes to your WordPress website I suggest making a full backup of both files and the database.

Was this post helpful?

Leave a Comment