Home > Help Center > Applications > WordPress > How to Change WordPress Domain

How to Change WordPress Domain

In this article we are going to show you how to change WordPress domain. We are not going to move the actual site to another root directory but will just change site's main domain.

In the example we'll replace hostpulse-demo.example.com with new-hostpulse.example.com. We remind you that in your tests you must replace the example subdomains with your own active sub/domains.

The expression sub/domain simply means there is no difference if you are using domain or subdomain as long as it is correctly configured.

First we need to create another sub/domain and configure it to work from the current site's root directory.

change wordpress domain

Old domain configuration:

change wordpress domain

New domain configuration:

change wordpress domain

Because we do not move files changing the domain name is a matter of replacing the old with the new sub/domains in the database.

We are going to show you two different ways how to do it – you need to choose only one of the three way that suits you best and you do not need to execute all three methods one after another.

Change WordPress domain from phpMyAdmin

From your cPanel > Databases click phpMyAdmin icon or link to open the program.

Expand the databases list if it is collapsed:

change wordpress domain

Click on the correct database name (if you are unsure take a look in wp-config.php file):

change wordpress domain

Click on *_options table.

We are using custom prefix hstpls_, the default WordPress prefix is wp_, yours might be different as well.

So click the table prefix_options

change wordpress domain

We are going to edit the URLs in the first two rows:

change wordpress domain

Click on the first Edit link:

change wordpress domain

Replace current domain with the new one and click Go button to save changes:

change wordpress domain

Repeat the same step with the second row – you need to have two identical URLs in both rows:

change wordpress domain

Now if you have been logged in with the old domain your session is destroyed and you'll see this screen:

change wordpress domain

Close the tab and enter in the browser the name of the new sub/domain new-hostpulse.example.com:

change wordpress domain

The site is working fine.

Enter http://new-hostpulse.example.com/wp-admin/ and login with existing admin credentials:

change wordpress domain

Administration also works properly with the new sub/domain.

Change WordPress domain in database archive

In this example we are going to export database archive, using find/replace feature we'll replace the old domain with the new one and we'll import the archive back to the database.

But this time we'll exchange the domains from the previous example – our current (old) domain is new-hostpulse.example.com and we'll replace it with hostpulse-demo.example.com.

We hope phpMyAdmin is still open. If it is not open it again and click on the database name:

change wordpress domain

Click on Export link:

change wordpress domain

Click Go button.

The database archive is downloaded to your computer (we recommend you to create copy of the archive):

change wordpress domain

Open the archive .sql file with your text editor (find/replace capabilities are required). In the example we'll use Notepadd++:

change wordpress domain

Enter from your keyboard CTRL+H to open Replace window or click Search > Replace:

change wordpress domain

Enter current domain new-hostpulse.example.com in Find what field.

Enter new domain hostpulse-demo.example.com in Replace with field.

Click Replace All button.

Close the window and click CTRL+S to save the archive file.

change wordpress domain

If you try to import the archive back to the database you'll get an error:

change wordpress domain

We need first to delete all database tables (not the database itself) and then to import the archive.

Click on the database name, click on Check All link to select all tables and from the dropdown menu select Drop option:

change wordpress domain

On the next screen confirm deletion by clicking Yes button in far right side.

change wordpress domain

Now click Import link, choose the archive file and click Go button:

change wordpress domain

Few seconds later you'll see confirmation message:

change wordpress domain

Again, if you are logged in the just replaced old domain your session will be destroyed by WordPress.

Close the browser tab and enter the new sub/domain hostpulse-demo.example.com in a new tab.

Both the site and the WP admin panel should work properly.

Summary

To follow successfully the example you need to be careful about these few things:

  • Configure new sub/domain to the site's root folder.
  • Check in wp-config.php file the correct database name and table prefix.
  • Copy/paste domain names carefully to avoid errors.

#wordpress #management

Still not finding what you're looking for?

Contact our support team with any additional questions or concerns.

Contact support