There are times when you’ll need to move a WordPress site to a new domain. You might want to move your site to a new hosting provider, or you might just want to change the domain name. In this post you'll learn how. It's easier than you might think!
The good news is that in most instances, moving a site to a new domain doesn’t actually mean you have to physically move the site. Instead, you can change the WordPress settings so your site behaves as if it’s moved domains. But it still stays where it is on your server.
Sometimes, moving your domain name will also mean moving your site. Maybe you want to find a better hosting provider. Or maybe you want to move your site into or out of a multisite network. In that case, you’ll need to migrate the site as well as setting up the new domain.
In this tutorial, I’ll help you identify whether you need to physically move your site or not, and then show you how to move your site to a new domain, both if you need to migrate the site and if you don't.
So let’s get started.
Moving to a New Domain Name: Do You Need to Migrate the Site?
In most cases, moving your WordPress site to a new domain name can be done without physically moving the site.
But sometimes you’ll either need or want to migrate the site as well. Here are some scenarios in which that might be the case:
- You want to redesign your site at the same time and change to a more suitable hosting plan.
- You’re unhappy with your hosting provider and want to switch.
- Your site is currently in a multisite network, and you want to move it to a standalone site.
- Your site is a standalone site, and you want to move it into a multisite network (as well as changing the domain).
In these cases, you’ll need to migrate the site as well as changing the domain name. I’ll show you how to do that shortly. But first, let’s look at how you live to a new domain name without actually moving the site.
Switching Domain Names Without Moving Your Site
Changing your domain name is a lot simpler than you might think. And you can do it by tweaking your WordPress settings and running a search for the old domain name in your database, using a plugin.
There are three steps:
- Register the new domain name and point it at your site.
- Configure the WordPress settings to use the new domain name.
- Edit the database or set up redirects so that internal links to your old domain name are replaced by links to the new one.
Let’s work through these steps.
Register the New Domain Name and Point It at Your Site
If you want to use a new domain name, the first step is to register it. Check that it’s available and, if so, register it under your name.
If your hosting provider also registers domain names, it’s simpler to do this with them—that way, you know your new domain name will point at your site.
But if your hosting provider isn’t also a domain registrar, or if you’ve also registered the domain name elsewhere, you’ll need to get it pointing at your site.
Check how you do this with your domain registrar. You’ll need to change one of the following:
- Nameservers: This will make all aspects of your domain name point to your hosting provider, including email addresses. So if you already have email set up using your domain name, you’ll either need to set that up again with your hosting provider, or use a different option. I tend to use nameservers and then direct email at Gmail using MX records.
- A records: Use this to point your domain name at the IP address where your website is hosted. Your hosting provider will be able to give you this.
Once you’ve done that, your domain name will point to the right place, although it can take anything up to a couple of days to work. You can use WhatsMyDNS to check if your DNS changes have propagated around the internet.
Your domain name is now pointing at your site, but your site will still behave as if it’s using the old domain name. So you need to configure some settings.
Configure Domain Settings in WordPress
In the WordPress admin, go to Settings > General. Look for the WordPress Address and Site Address fields. Edit these so they have your new domain name instead of the old one.
Scroll down and click the Save Changes button to save your new domain name. Your site will now work on the new domain name.
Your site is now using a shiny new domain name, but there could still be a problem, and that’s links.
Redirect Links Using the Old Domain Name
If you’ve shared links to your site using the old domain name, anyone using that link will only be taken to the new site if you still have your old domain name pointing at it (which you should). And even if that’s the case, they won’t be taken to the correct page in the site—they’ll either find themselves on the home page or the 404 page.
So any important links need to have redirects set up. Install a redirection plugin like the free Redirection or the more full-featured premium Advanced WP Redirect plugin and create redirections from the relevant posts or pages using the old domain name to those using the new domain name.
Alternatively, you can set up a wildcard redirect from the old domain name to the new one, using a plugin or using cPanel in your hosting provider’s dashboard. This will catch any old links and send them to a link with the same slug using the new domain name.
With the redirection plugin, you can set up a wildcard redirect, which will redirect all slugs using your old domain name to the same slug on your new domain name. This means you have to keep the slugs for your posts the same when you change domain names, and that you mustn’t change the URL structure of your permalinks. If you just leave everything as it is, you won’t go wrong.
You’ll need to enable regex functions first, as the wildcard asterisk is a regex function.
Go to Tools > Redirection and go to the Add new redirection section of the screen.
Click on the URL Options/Regex drop-down and check the Regex box.
In the Source URL field, type the old path with a wildcard. It needs to take the form
/(.*)$. The entry for Target URL needs to take the form
Click Save Changes to save your redirect settings.
Remove Internal Links Using the Old Domain Name
Redirects work for links you’ve shared externally. But for links internal to the site, there’s a better fix, and that’s to edit those links to point to the new domain name.
Install a plugin like Better Search Replace and use it to replace all instances of the old domain name in your database with the new domain name. This means any internal links in your post or page content or in widgets will be updated to reflect the new domain name.
Before you do this, you should always back up your database. This process involves directly editing the database, and if you do it wrong, it’ll be difficult to undo. So use your backup software of choice to make a backup and save it somewhere safe.
Then go to Tools > Better Search Replace to access the plugin screen.
In the Search for field, type in your old domain name. In the Replace with field, type in your new domain name. It’s a good idea to include the https:// or https:// so you don’t find yourself replacing instances of email addresses that haven’t changed. If you do, make sure you do it for both the search and replace fields.
Note: When you set up your new domain name, it’s good practice to add SSL to your site so it’s at https://yourdomain.com. Set this up before running a search and replace and use https:// in the replace field. Learn how to set up SSL with our free guide.
- WordPressHow to Secure Your WordPress SiteRachel McCollin
- WordPressHow to Install an SSL Certificate to Secure WordPressRachel McCollin
Next, you can select the tables you want to search. Either leave this at all tables, or select the wp_posts table to replace instances of your domain in your posts and pages—this normally picks up everything you need.
Keep Run as dry run checked so you can test things before editing your database (not something you should do lightly).
Click the Run Search/Replace button to run the search. The plugin will tell you how many instances of your search term it found and give you the opportunity to run the replacement again for real. You can also check the list of results it returns. If you’re happy, run the search/replace for real.
You may then find you have to log in to your site again because of the domain change, or that you have to refresh your browser cache to get rid of old links in any cached pages. Do this and your site should be running with the new domain name throughout.
One word of warning: if there are any valid instances of the old domain name (e.g. email addresses) in your post or page content, you’ll need to exclude these from the search replace.
Your site will now be working on the new domain name—and you didn’t have to physically move the files at all.
Migrating Your Site to a New Location and Domain Name
But what if you do actually need to move your site from one place to another, as well as moving the domain name?
Moving your site will take a little longer, but can be done.
There are four possible ways to do it:
- Ask your new hosting provider to run the migration for you, if you’re switching hosting providers. Most providers will do one migration for free.
- Use an automated tool provided by your hosting provider to run the migration, if they provide one. SiteGround, for example, has a migration tool that you install on your old site, and it automatically moves all of your content and settings to your new site.
- Use a migration plugin to migrate your site from one place to another. CodeCanyon has a number of migration plugins that will do this for you.
- Run the migration manually. This will involve copying the files and the database as well as installing WordPress in the new location. You can find out how to do this in our guide to migrating WordPress manually.
- WordPressHow to Migrate a WordPress SiteRachel McCollin
- WordPressMoving WordPress: Moving Your Site ManuallyRachel McCollin
If your site is moving into or out of a multisite network, this will complicate things—but not make them impossible. You can either use a migration plugin that supports multisite, or follow our guides to manually migrating WordPress out of a network or into a network.
Moving your WordPress site from one domain to another doesn’t have to mean moving your site at all. Instead, you can just point the domain name at your site and make some changes to the settings, and you’re done.
But if you do need to physically move your site, then it’s not so hard as you may think. Follow the tips above, and you’ll soon have your site working on your shiny new domain name.
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
- WordPress25 Best WordPress Slider & Carousel Plugins of 2021Daniel 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
- WordPress18 Best WPBakery Page Builder (Visual Composer) Addons & Plugins of 2020Daniel Strongin
- WordPress Themes30 Best Coaching & Consulting WordPress Themes for 2021Brenda Barron
Subscribe below and we’ll send you a weekly email summary of all new Web Design tutorials. Never miss out on learning about the next big thing.Update me weekly
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post