You’ve decided it is time to change the domain on your website. Maybe you are doing a rebrand or switching a testing site to the live domain. Whatever the reason, the process for changing the domain on a WordPress site is reasonably straightforward. This article will take you through the process.
- Setting Up Your New Domain.
- Changing The Domain Name In WordPress.
- Redirect Your Old Domain.
- Notify Search Engines.
Setting Up Your New Domain
The first step to changing your domain is to configure your new domain to point to the correct website.
If you have not registered your domain.
You will need access to your domain’s DNS settings to point the domain to your server. If you do not yet own the domain it is time to purchase it using a domain registrar. You likely already have a registrar you use for the old domain, so it may make sense to purchase the domain using the same registrar.
If the domain is already registered you’ll need to get access to the domain’s DNS settings or find a different domain to register.
Add the domain to your server
Your server will need to know the new domain belongs to your website so you’ll need to add the new domain there. Each host has a little different process for adding a domain, so you’ll want to consult your host’s documentation.
Testing the domain
You may point your hosts file to the server to verify everything is working on the server before pointing your DNS.
Add 1 line to your host file, changing the <domain>
and <IP>
respectively:
<IP> <domain>
Point the DNS
Point the main A
or @
record of the domain to the IP address of your server or load balancer. If you do not know this IP, your host will be able to provide it for you.
Changing The Domain Name In WordPress
Now it is time to update the domain in WordPress. This process involves a few simple steps.
Now might be a good time to make a full backup, in case something goes wrong.
1. Update the wp-config.php file
In the root of your WordPress site’s files you will find a wp-config.php
file. There are 2 possible PHP constants which, if exist, will need to be updated.
- In your
wp-config.php
file, the “https://example-old-domain.com” will match your old domain. - The PHP constants may be spread out in the file, unlike the example.
- Either or both the constants may not exist, in which case you can skip updating non-existent.
Change your old domain do the new domain in both constants.
2. Change the domain in General Settings
Head over to your WordPress admin to the Settings -> General screen.
Update the following settings to point to your new domain:
- WordPress Address (URL).
- Site Address (URL).
Hit the “Save Changes” button to save the new URL.
3. Update the domain throughout the database.
Changing the domain via General Settings will make any new URL point to the new domain but any URL which previously existed throughout the database will still point to the old URL. To update all existing URLs we turn to the Go Live Update Urls plugin.
- Install the plugin using the plugin’s instructions.
- Go to the Tools -> Go Live page in your WordPress Admin.
- Enter your old domain in the “Old URL” field.
- Do not include the “https://” or trailing “/”.
- Example: “old-domain.com”
- Enter your new domain in the “New URL” field.
- Do not include the “https://” or trailing “/”.
- Example: “new-domain.com”
- Click the “Update Urls” button.
Redirect Your Old Domain
For awhile after you change your domain, you will likely continue to receive traffic on your old domain. This is because search engines or other sites will have content which points to your site using your old domain.
To maximize SEO and the migration of requests to your new domain, you’ll want to:
- Keep your old domain intact.
- Keep your old domain pointed to the IP of your website.
- Redirect requests for the old domain to your new domain.
Many hosts will support using a .htaccess file to configure server directives like redirects.
If your host supports .htaccess
You may add the following to the .htaccess file found at the root of your WordPress files.
- Replace “old-domain” with your old domain.
- Replace “new-domain” with your new domain.
More information may be found here.
If you host does not support .htaccess
Each host has a slightly different process for adding redirects. You’ll want to consult your host’s documentation for how to add a redirect on their platform.
Basically, you want to redirect your old domain to your new domain.
Notify Search Engines
The final step is optional but will greatly reduce the time it takes for search engines to convert all your content to the new domain. Your SEO rankings will also migrate faster and more reliably.
- The instructions for Google may be found here.
- The instructions for Bing may be found here.
Conclusion
Following this guide should allow you to have a successful stress-free domain migration experience. Our support team is happy to help if you have additional questions or get stuck.