How to Change a Website Domain Name

Changing the domain name of a website is actually very easy. You only need to make some modifications to the website's PHP code.


When you make modifications, you must be careful because if you make a wrong code change, the website will not function properly. Therefore, there are several things you need to do before changing the domain name.

Backup Data WebsiteLangkah pertama sebelum Anda melakukan perubahan kode PHP untuk mengubah nama domain, terlebih dahulu Anda backup semua data website. Agar ketika nanti mengalami masalah, website bisa dengan mudah dipulihkan.
Punya Akses ke cPanelKarena metode cara mengubah nama domain ini dilakukan dengan modifikasi file PHP. Oleh karena itu, Anda memerlukan akses ke cPanel, agar bisa membuka file PHP yang akan dimodifikasi.
Memiliki Domain BaruTentu saja memiliki domain baru adalah hal yang utama, namun yang perlu diperhatikan sebelum menentukan nama domain yang baru. Kami sarankan Anda untuk melakukan beberapa riset dana brainstorming sejumlah nama domain yang potensial, agar dikemudian hari tidak melakukan pergantian nama domain lagi.

Buying a New Domain Name

The first step before you replace the domain with a new one is to prepare the new domain, make sure your new domain will match the theme and description of your business.

Once you've done your research, buy your domain ID using the domain promos we share on this website. Easy, right? Let's move on to the next step!

Change WordPress URL

Once you've set up your new domain name. The next step on how to change a domain name on a website is to add the domain to WordPress General Settings.

The method is as follows:

Step 1: Go to dashboard > Settings > General.

Step 2: Once open, replace the current WordPress Address and Site Address with your new domain. Then click Save Changes.

Note: Do not access the new domain yet, as the process is not complete so you need to proceed to the next step first..

Make Changes to the wp-config.php File

Now the next step is to make changes to the wp-config.php file. You can access this file through the cPanel page or you can also use the FileZilla software. However, in this demo we are using cPanel.

Step 1: Login to your website's cPanel hosting first.

Step 2: Go to Files > httpdocs > wp-config.php.

Step 3: Copy and paste the code below into your wp-config.php file and replace your old domain name with a new one.

define(‘WP_HOME’,’http://yoursitename.com‘);

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

Here is the display after changing the domain name.

That's it, let's move on to the next step!

Update Website Database

Perform the steps below to update the database:

Step 1: Open the databases > phpMyAdmin.

Step 2: Select the database that stores the WordPress file and click Enter phpMyAdmin.

Step 3: On the phpMyAdmin page, find the wp_options file (the name may vary).

Step 4: Make changes to the Site URL line as well as the home.

Step 5: Replace your old URL with the new domain name. Click Go.

Switch Old Domains Permanently

The last step you can take in this discussion of how to change your domain name is to permanently switch your old domain to a new domain. The goal is that the Google PageRank information that you have done so far is not in vain even though it uses the old domain.

So for the time being, we recommend that you keep the old domain active. The goal is for website visitors to realize that there is a change from the old domain to the new one. Here are the steps you can apply to switch the old domain to the new domain:

Step 1: Open the cPanel.

Step 2: Open Files > httpdocs.

Step 3: Find the file .htaccess.

Step 4: Open and edit the file.

Step 5: Copy and paste the code below.

#Options +FollowSymLinks

RewriteEngine on

RewriteRule ^(.*)$ http://yoursitename.com/$1 [R=301,L]

Your old domain in the code is replaced with a new domain.

That's it, now you've successfully implemented how to change your domain name properly and correctly.

Change Your Domain Name Now!

Anyone who thinks about changing their domain name has a reason, such as rebranding and so on. One of the great things about WordPress is that you can customize the default domain address by modifying the PHP code in your cPanel account.


In this post, we'll go through the steps of how to change your domain name to a new one. It starts with buying a new domain name and then changing your website's address in the WordPress settings page.


This is followed by modifying the wp-config.php file via the cPanel or FTP client. After that, you'll need to make changes to the website's databases and close by modifying the .htaccess file so that old visitors on the old domain are redirected to the new domain.


Good luck!

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.