Change Domain Name in WordPress

Change Domain Name in WordPress

Change Domain Name in WordPress

WordPress domain name provides a means of finding and identifying a site on the web. Think of it as an ID you use at work; it’s what others use to identify you. As such, change domain name in WordPress – or in simpler terms, site address – of your site is a delicate issue. Delicate because if not done correctly, things could go wrong.

Many webmasters have reported about their website crashing, losing its functionality, and in some cases being hacked when they change domain name.

Nevertheless, there will be times when the need to change your WordPress site URL (domain name) will arise.

For instance, when you are looking to rebrand your business, you might have to change your website address to reflect the new business name. Or perhaps, you wish to move your site from HTTP to HTTPS.

These are just a few of the many circumstances that will warrant you to change your URL.

The good news is, whatever the reason for wanting to change domain name for your site, there are ways you could do it without compromising the integrity of your site.

In this article, we will show you how to change your WordPress address URL. So stick around.

Content:

Domain Name, Site URL and Site Address: What’s the Difference?

Often times, people use domain name, site URL and address interchangeably. In fact, if you noticed, in the introductory part of this article, we interchanged the terms at different points.

Does it mean the three terms all mean the same thing? Not exactly.

A domain is basically the address where your website lives on the internet. Now, your website may have several pages, posts, and files, it can only have one domain name.

Think of your office address, for instance. The building might have different floors and rooms with unique IDs (e.g. floor 2, room 302), it can only have one address (e.g. 10 Dow Jones Street, California).

A URL, on the other hand, is the address/path to a specific page, post or file on the internet. With the office example we used above, it’s more like the address to a particular room in the office building.

For instance, take a look at this post on our blog: In this post, we explained how to perform a  WordPress domain transfer from HTTP to HTTPS, by installing an SSL certificate.

WordPress URL - Change domain name in WordPress

The URL to this post can be seen highlighted at the very top of the page, and it reads:

https://www.fixrunner.com/http-to-https-wordpress/

If you copied this link to your web browser, you will specifically be taken to this post. Not the home page of the site or another page, but the post.

Lastly, site address is a generic name used to either refer to the domain name of a website, or a URL within the site.

With that said, let’s now see some of the techniques you can use for changing your domain name.

How to Change Domain Name in WordPress

There are a number of methods for changing the URL address of a website. However, we will only be considering three of them.

Namely: via WordPress dashboard, via FTP client or cPanel, and then via WordPress database.

Via WordPress Dashboard

The admin dashboard of WordPress can be considered as the central command unit of WordPress. You can alter, tweak and change your WordPress websites via the admin dashboard.

To get started, log into your WordPress admin area. Navigate to Settings >> General Settings.

Change domain name in WordPress admin

On the next page, you will see a WordPress Address URL and Site Address URL block.

change domain name in general settings - wp dashboard

In both blocks, replace the old site address with the new one you intend to use. Ensure both fields match each other.

Note: The http(s):// part should be included in both settings. A trailing slash / should not be at the end.

When you are done, scroll down and Save Changes.

To avoid redirect errors after changing the URL to your website, clear your website’s cache.

Change Domain Name Through FTP Client or cPanel

One of the easy methods to change your domain address is by making edits to the wp-config.php file. As a matter of fact, this technique can override whatever changes you might have made via your WordPress admin dashboard.

But since this file lives on your server, you have to access it via FTP using FileZilla. Or with cPanel.

Once you have accessed the file, open it with a text editor of your choice.

If FTP seems to be so much of a work, you can use the cPanel.

To begin with, log into cPanel with your login credentials, then click on File Manager.

cPanel

After that, scroll down to public_html in the domain folder. Double click on it.

File Manager

On the next page, upon scrolling down you will find the wp-config file.

Change domain name by editing wp-config

Right-click on it and click Edit.

Copy and paste the following code into the file, preferable toward the end of the page.

define('WP_HOME','https://mynewdomain.com');

define('WP_SITEURL','https://mynewdomain.com');

With the code copied and pasted, Save Changes to the document and exit. But you are not done yet; you still need to set up redirects.

Setting up redirects properly ensures that anyone that tries to access your website via the old URL will be redirected to the new one.

To do this, access and open your website’s htaccess file.

Then paste the following code into it.

#Options +FollowSymLinks

RewriteEngine on

RewriteRule ^(.*)$ https://www.mynewdomain.COM/$1 [R=301,L]

Like we did previously, replace mynewdomain.com with your new domain name.

These few lines of code will configure WordPress to redirect links appropriately.

Change Domain Name Via WordPress Database

The last technique we shall be considering is via the database.

To begin with, log into your cPanel account and navigate to phpMyAdmin.

phpMyAdmin

With the database page open, on the left-hand pane, click the + button right in front of your database name.

WordPress database

A drop-down list will appear. Click on wp_options (note that your database may have a prefix other than wp_).

WordPress URL - Change domain name in WordPress

Then edit the siteurl and home rows.

WordPress site URL

Here, paste in your new domain URL. When you are done, click Go

WordPress domain

And with that, you are done.

Conclusion

Changing the site address URL of WordPress websites is a risky adventure that should be avoided whenever possible.

However, certain circumstances can warrant the need for you to change your site address. We discussed a couple of them here.

Whenever you find yourself needing to change your website address URL, endeavor to follow the techniques we shared here.

That way, the risk of your entire site coming down is minimized.