If you’ve been running a WordPress site for a long time, you may find that your domain name doesn’t work for you anymore.
Maybe you’ve changed your business name, and you need your domain name to reflect that.
Maybe you want a more SEO-friendly domain name.
Or maybe your perfect domain name wasn’t available when you first created your site, and now it is.
You might be thinking that once you’ve set up your website and got your domain name pointing to it, you’re stuck with that domain name. The truth is, you’re not.
In this tutorial, you'll learn how to change the domain name of your WordPress site without having to create a new site. By following along, you'll be able to change the WordPress site URL without losing any data.
I'm using SiteGround for this example, but the steps are similar for other WordPress hosting providers.
I'll start by showing you how to get a new domain name pointing to your site in the SiteGround hosting admin screens, and then I’ll show you the changes you need to make in your site’s admin settings. If you just want to see how to update your WordPress admin settings, you can skip to the next section.
Discount for WordPress Hosting
If you're looking for a WordPress hosting provider, check out SiteGround. It comes with an easy installer, free support, and automatic updates. We're happy to be able to offer a discount of 70% off self-managed WordPress hosting, thanks to our partnership with SiteGround.
Changing the Domain Name That Points to Your WordPress Site
The first step is to get your new domain name pointing to your WordPress site.
This is easier than you may think; in fact, you can have more than one domain pointing to your site. So if you just need an extra domain name, you only need to follow this step.
Note: Any links to your content using the old domain will take people to your 404 page or your home page. To fix this, you’ll need to set up redirections, which you can do with a plugin or in the SiteGround admin screens.
Pointing a Domain Name at Your Site From a Domain Registrar
If you bought your new domain name from a domain registrar that isn’t also your hosting provider, you’ll need to start by telling the domain registrar that the domain name needs to point to the server that your site is hosted on.
In SiteGround, you can find information about your server’s address by logging in and then clicking on Websites > Site tools > Dashboard.
Scroll down to the Site Information section, where you'll see your IP address and nameservers.
Use the nameserver addresses with your domain registrar to have your domain point to the nameservers your site is using on SiteGround.
Note: If you’re using email provided by your domain registrar, you’ll need to use DNS settings instead. If you’re using a third-party service such as Gmail, you can point your domain to SiteGround’s nameservers and then point your MX records to Gmail.
Registering a Domain Name With SiteGround
If you want to register the domain with SiteGround, you need to do this before setting it up as the primary domain.
Log in to your SiteGround account and go to Services > Domains.
Click the New Domain button at the top right to be taken to a screen where you register your new domain name.
Type in the domain name you want. If it’s not available, keep trying alternatives until you find an available one that’s suitable. Work through the process of paying for and registering the domain name.
It will now be displayed in your account if you go to Services > Domains.
Changing Your Site’s Primary Domain With SiteGround
Log in to your SiteGround account and click the Websites option at the top of the screen to go to the website management screen.
Find the website whose primary domain name you want to change, and click on the three dots to the right to reveal the shortcut menu.
Select the Change Primary Domain option.
In the next screen, type in the new primary domain. This will not register a new domain for you—you need to have already registered the domain and have it pointing to your nameserver at SiteGround.
The system will then process your request and give you a success message when that’s done.
Adding SSL to Your Domain
Before you configure your domain in the WordPress dashboard, it’s a good idea to add SSL to it. This means you’ll be using https:// in front of your domain instead of https://.
SSL will enhance security when people are providing data on your site. It’s essential if visitors are going to be inputting personal details to your site or buying products or services from you. And it has SEO benefits too; Google will rank sites with SSL more highly than those without.
The good news is that adding SSL to your new domain is free using the Let’s Encrypt service. You can either use a plugin to do it, or if you’re with SiteGround, you can do it via the SiteGround dashboard.
Adding SSL With SiteGround
In SiteGround, click on the Websites tab and then the Site Tools button for the site you want to change.
In the admin menu on the left, click on Security > SSL Manager.
In the Install New SSL box, click the Select Domain dropdown box and select your primary domain. In the Select SSL dropdown, select Let’s Encrypt.
Click the Get button and wait for the system to process your request and create your SSL certificate.
Adding SSL With a Plugin
If you’re not with SiteGround, you may find that your hosting provider gives you access to Let’s Encrypt using their dashboard or the cPanel software. Check with them to find out if it’s available.
If not, you can use the SSL Zen plugin to add free SSL to WordPress.
Start by installing the plugin. In your WordPress admin, go to Plugins > Add New. Type SSL Zen into the search box.
Click the Install Now button. Once WordPress has installed the plugin, the button will change to say Activate. Click it again.
You will be automatically directed to the setup screen. If not, go to SSL Zen in the admin menu. Click the Use free version link at the top to be taken to the admin screen for the free version of the plugin.
Your domain name will be pre-populated. Enter your email address, check the terms and conditions radio button, and click the Next button at the top right of the screen. Continue working through the wizard, including verifying domain ownership. Once you’ve worked through it, you’ll have a free SSL certificate on your website.
Telling WordPress to Use the New Domain
Now that you have your domain configured, you need to ensure WordPress knows what the correct domain is. There are a few ways you can do this:
- in the WordPress admin
- using WP-CLI
- in phpMyAdmin
Let’s take a look at these in turn.
Configuring the Domain in the WordPress Dashboard
The final step is to change the settings for your domain in the WordPress admin screens.
If you used a plugin to install the certificate, this may have already been done for you—but check first.
Don’t do this until you’re satisfied that the new domain name is pointing at your site. Sometimes it can take up to two days for DNS changes to take effect, so you need to check this is working.
You can check it by visiting the new domain name in your browser or by using the What’sMyDNS site.
Once your domain name is resolving correctly, it’s time to change your WordPress settings.
In your site admin, go to Settings > General.
In the WordPress URL and the Site URL fields, change the URL to your new domain name. Remember to use https:// if you’ve added SSL to your domain (which I would recommend).
Now scroll down and click the Save Changes button. Your site will now resolve to the new domain name.
Once you’ve done that, you might find that you still have links in your posts that use the old domain name and URL. You need to replace these with links using the new URLs.
Use the Better Search Replace plugin to do this, replacing the old domain with the new domain throughout your site.
Configuring the Domain Using WP-CLI
If you’re using WP-CLI to manage your site instead of the WordPress admin, you can set up the new domain at the command line.
Start by connecting to your server using SSH in the way you normally do. Then make a backup of your database before you make the changes, with this command:
wp db export
This command will create a backup of your database into an SQL file. Once you’ve done that, type this command:
wp search-replace 'https://olddomain.com' 'https://newdomain.com'
Replace olddomain.com and newdomain.com with your old and new domains in the command above. This will find all instances of the old domain in your database and replace them with the new domain.
Once you’ve done this, you need to flush your website’s cache with this command:
wp cache flush
And that’s it. Your site will now work with the new domain name.
Configuring the Domain in phpMyAdmin
The final option is to use phpMyAdmin to configure the new domain name with your site. Before you do this, take a backup of your database using the SiteGround backup tool (Site Tools > Security > Backups) or with your backup plugin.
In the SiteGround dashboard, go to Site Tools > Site > SQL. Click the phpMyAdmin tab on the screen.
Click the Access phpMyAdmin button to open phpMyAdmin.
Click the Databases tab and select the database for your site. Click on the wp_options table (or the xx_options table if your tables have a different prefix where xx is the prefix, as they will if you used the SiteGround WordPress auto-installer).
In the option_name column, find the siteurl and home fields.
For each of them, click the Edit link and then replace the existing domain name with the new domain name. Click Go to save your changes.
Exit phpMyAdmin and clear your browser cache, and then check your site on the new domain. It should be working.
Note: If there are links in your posts that use the old domain name, you’ll need to replace those in the database. Use the Better Search Replace plugin to do this.
Your site will now work with the new domain!
Changing the domain name of your WordPress site does involve a few steps, but it is something you can do.
Follow the guide above to point your new domain at your server and then configure WordPress to use the new domain, and then your site will function on the new domain as if it had always been there.
The Best WordPress Themes and Plugins on Envato Market
Explore thousands of the best WordPress themes ever created on ThemeForest and leading WordPress plugins on CodeCanyon. Purchase these high-quality WordPress themes and plugins and improve your website experience for you and your visitors.
Here are a few of the best-selling and up-and-coming WordPress themes and plugins available for 2020.
- Inspiration23+ Best WordPress Portfolio Themes for CreativesBrenda Barron
- WordPress17 Best WordPress Slider & Carousel Plugins of 2020Daniel Strongin
- WordPress20 Best WordPress Calendar Plugins and Widgets (+5 Free Plugins)Daniel Strongin
- WordPress Themes28+ Best Responsive WordPress Themes (For Sites in 2020)Brenda Barron
- WordPress22 Best WPBakery Page Builder (Visual Composer) Addons & Plugins of 2020Daniel Strongin
- WordPress Themes25+ Best Coaching & Consulting WordPress Themes (2020)Brenda Barron
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post