WordPress

How to Change WordPress Domain Name: A Step-by-Step Guide

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. –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 nameproper 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.Using Hostinger's domain checker

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.Updating WordPress general settings

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:

  1. Head to hPanel -> Files -> File Manager.
  2. Choose the domain and click Go to File Manager.
  3. Locate the wp-config.php file in the public_html folder.
  4. Right-click and select Edit.
  5. In the following snippet, replace http://yoursitename.com with your new WordPress domain name, then insert it into the file and press Save & Close.
define('WP_HOME','http://yoursitename.com');

define('WP_SITEURL','http://yoursitename.com');

Your wp-config.php file should look like this”Editing the wp-config.php file using a new domain name

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:

  1. Navigate to hPanel -> Databases -> phpMyAdmin.
  2. Choose the database where your WordPress files are located and click Enter phpMyAdmin.
  3. On the phpMyAdmin page, find the wp_options file.
  4. Select Edit on the site URL and home rows.Editting the wp_options file using a domain name
  5. 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:

  1. Go to hPanel -> Files -> File Manager.
  2. Select your old domain and click Go to File Manager.
  3. Find the .htaccess file in the public_html directory.
  4. Right-click and choose Edit.
  5. 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]

Editing the .htacces file using a new domain nameSame as with the modifying wp-config.php, this step can be completed with an FTP client.

Conclusion

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:

  1. Purchase your new domain name.
  2. Change your website’s address in your WordPress settings.
  3. Update the wp-config.php file through the hPanel or an FTP client.
  4. Update the site’s database.
  5. Tweak the .htaccess file to redirect visitors and search engines to your new domain.

Give it a try and good luck!

About the author

Freddy M.

Freddy is a WordPress theme reviewer at WP Theme Raves, a published WordPress blogger, web dev and founder of Vista Media Enterprises – an online business dedicated to WordPress users looking to boost conversion rates through content marketing. He shares his wealth of experience here.

1 Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Hi, really very helpful article i want to say thank you very much for sharing this types of the article please keep updating us.
    Thanks

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!

More in WordPress
How to Backup Your WordPress Site
How to Back Up Your WordPress Site in 2019

Close