Ways to change website domain names on WordPress

If you are using a WordPress website, you may want to change the domain name at a certain time. Here's how to change the WordPress website domain easily.

Whether it is to find a better new domain name or an existing domain name for temporary use, if you do not know how to change a new domain for a website on WordPress, this is the way for you. Note that before changing, you will need to take some action to ensure the security of the posted content.

Prepare the necessary information

Before renaming the website domain, you need to have the following information:

  1. WordPress login information including username (or email) and password.
  2. Login information cPanel or file manager.
  3. FTP login information.
  4. Access to PHPmyAdmin on the control panel.

Don't forget to back up all settings on WordPress. Here are 4 ways to change domain names for WordPress websites. The first two ways will be easier, if not effective, then the second way.

1. Change domain names on the admin panel of WordPress

This is the simplest way to change domain names for your WordPress website. Just log in to your WordPress account, then go to the General Settings page , you will see two options: WordPress Address (URL) and Site Address (URL).

Picture 1 of Ways to change website domain names on WordPress

Change these two URLs to the domain you want, in most cases they will be the same. But they will be different if you store WordPress files on a different directory than the domain used to access the site. In that case, WordPress Address is the directory where the WordPress file is stored, and Site Address is the address that others use to find your site.

If you can access the admin panel, this will work, otherwise try the second method.

2. Edit the database via PHPmyAdmin

Before editing, remember to back up on cPanel or any other control panel you are using. Go to PHPmyAdmin and find WordPress data in the left column. Click to select, you will see the list of tables appear under the name of the database. Find the table named wp_options and click on it. This table contains 2 lines that you need to fix: siteurl and home. Now edit the domain you want to use.

3. Edit wp-config.php file

If the above two methods don't work, fix the wp-config.php file directly. You can edit this file inside the file manager or download it to fix it and upload it to the FTP Client. Please correct the two lines of code that define the website URL as shown below.

Picture 2 of Ways to change website domain names on WordPress

Replace example.com with the domain name you want to change. This way will change the domain but should only choose when other ways are not possible. When manually editing the wp-config.php file , you have changed the page value on the website and cannot edit these values ​​using the General Settings section of the admin panel.

4. Edit the functions.php file to update the database

This is only a temporary command and should not be used as a long-term solution. Use this method only when all of the above methods are ineffective or you cannot access the website via the front-end. Please add the following two lines of code after the line "

Then upload the edited file to the page and log in to the admin page several times. This operation will update the database. When the page has accepted changes, delete these 2 lines of code from the functions.php file and the database will still update the previous state.

If the WordPress theme does not have the functions.php file, you can create it yourself by wrapping the above two lines of code into the tag php tags as below.

Picture 3 of Ways to change website domain names on WordPress

Save the above code as text file and upload to the theme's main directory. Then log in to the admin panel several times and remember to delete this file after the database has been updated.

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile