Sometimes, you want to change the domain name used by a WordPress installation, e.g. if you’ve developed a new website using a temporary domain and now want to publish the site on the correct one. This guide details what you need to consider before changing the domain name.
Preparations
Before you change the domain name used by your WordPress installation, there a few things to check and consider:
- If the domain you’re about to change to isn’t added to your web hosting account already, this needs to be done. Add it as an addon domain, and ensure that you set the same document root for the new domain as is currently being used by the site’s old domain. If the old domain is the main domain of the account, or is added as an alias, the document root will be
public_html
. If the old domain is an addon domain, you can see what the document root is on the same page as where you can change it. - If the new domain is already added to your web hosting account, you have to make sure that it uses the same document root as the old domain name. If the old domain is the main domain of the account, or is added as an alias, the document root will be
public_html
. If the domain is added as an addon domain, you can see the document root on the same page as where you can change it. - Make sure that the new domain is pointed towards the same IP address as the old domain. You can see where the domain points using e.g. mxtoolbox.com.
- If both domains point at the same IP address you’re done with the preparations. If the new domain name points at a different IP address, you need to edit it so it points towards the same IP address as the old domain. If the new domain has its DNS management with us, you can edit it via cPanel.
Changing the URL using WP-CLI
Now it’s time to change the domain name used by your WordPress site. All instances of the old domain name need to be replaced in the database, and while it can be done via phpMyAdmin we recommend that you use WP-CLI for the operation. WP-CLI is a tool that’s available via the terminal through cPanel, and also via SSH.
We have an entire guide dedicated to WP-CLI, and you can find it here.