Some projects eventually need to be rebranded under a different name. This article will show you step-by-step how to change WordPress domain name for a WordPress website.
Why Change Your Domain Name?
In many cases, changing WordPress domain name is inevitable. The most common scenarios are:
- Rebranding – you want to rebuild your company’s image with a new brand name. Here, a new domain reflects your rebranding strategy’s consistency. Some prominent brands like Twitter applied this marketing strategy very successfully.
- Domain Extension Change – if you currently running a website on a subdomain like mywebsite.wordpress.com, or you’re using a less popular extension like .mobi or .shop which doesn’t resonate well with your audience, swapping to a different extension can be a great idea!
How to Change WordPress Domain Name?
For the most part, the steps to change WordPress domain are simple, but some tasks will require you to tweak your site’s PHP code.
Keep in mind, modifying the code might put your website at risk if you don’t do it the right way. Be sure to follow these prerequisites before changing the domain name:
- Full backup of your site. – a full backup helps you restore or recover your website as fast as possible if you run into any issues. You can automatically back up your site via a plugin or your hosting provider’s file manager.
- hPanel or an FTP client – if you want to change WordPress domain, you’ll need access to your hPanel by logging into your Hostinger account or use an FTP client.
- A new domain name – proper research is required before settling down on your final decision.
1. Purchase a New Domain Name
First and foremost, head to Hostinger’s domain checker and type in your preferred domain. You’ll find out if your option is available, and get some suggestions on a few alternatives.
From there, add your domain to the cart, and proceed to check out. Alternatively, you can also get free domain registration for the first year if you purchase Hostinger’s annual Premium or Business shared hosting plans.
2. Change Website URL Using the WordPress Admin Dashboard
The next step to change WordPress domain is to add your new domain to the WordPress General Settings.
Head to Dashboard -> Settings -> General. Replace your current WordPress Address (URL to visit your site) and Site Address (URL of your core files) with your new domain. Hit Save Changes once you’re done.
We’re not done just yet. Before re-accessing your site using the new address, complete the following remaining steps.
3. Update the wp-config.php File
To reflect the changes you made in the WordPress settings, you have to edit the wp-config.php file. You can access it from the hPanel’s file manager or by using FileZilla. For this example, we’ll be using the hPanel:
- Head to hPanel -> Files -> File Manager.
- Choose the domain and click Go to File Manager.
- Locate the wp-config.php file in the public_html folder.
- Right-click and select Edit.
- In the following snippet, replace http://yoursitename.com with your new WordPress domain name, then insert it into the file and press Save & Close.
Your wp-config.php file should look like this”
If you prefer using an FTP client, the process will be almost identical. You’ll just need to use the FTP account credentials to access the site’s files.
4. Update Your Database
Next, you’ll have to update your WordPress site’s database:
- Navigate to hPanel -> Databases -> phpMyAdmin.
- Choose the database where your WordPress files are located and click Enter phpMyAdmin.
- On the phpMyAdmin page, find the wp_options file.
- Select Edit on the site URL and home rows.
- Replace the current URL with your new domain and press Go.
5. Redirect Old WordPress Domain Permanently
The final step to change WordPress domain requires you to create a 301 redirect – a URL redirection from your old domain to the new one. Additionally, the redirect will carry over Google’s PageRank, making sure that all of your efforts put into SEO doesn’t go to waste when moving to a new domain.
We recommended keeping your old domain active for a while. This both allows users to find you if they’re not aware of the domain change and lets the search engines recognize the redirection.
Let’s dive into the hPanel to edit the .htaccess file and create a 301 redirect:
- Go to hPanel -> Files -> File Manager.
- Select your old domain and click Go to File Manager.
- Find the .htaccess file in the public_html directory.
- Right-click and choose Edit.
- Insert the following code, after replacing http://yoursitename.com with your new domain, then press Save & Close.
#Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$ http://yoursitename.com/$1 [R=301,L]
Same as with the modifying wp-config.php, this step can be completed with an FTP client.
There are many reasons why you would want to change WordPress domain name. Luckily, WordPress provides a built-in URL address settings and allows you to manually tweak the PHP code through a file manager or an FTP client to effectively change your domain.
In this tutorial, you’ve learned the steps required to change your WordPress domain. Here’s a quick recap:
- Purchase your new domain name.
- Change your website’s address in your WordPress settings.
- Update the wp-config.php file through the hPanel or an FTP client.
- Update the site’s database.
- Tweak the .htaccess file to redirect visitors and search engines to your new domain.
Give it a try and good luck!