1. Knowledge Base
  2. >
  3. Results
  4. >
  5. Changing the Domain of Your WordPress Site

Changing the Domain of Your WordPress Site

As a business entity, you may want to promote a popular product known by more than one name, and you would like to use separate domains for each product. This is when you may need to duplicate your WordPress site's content and use it on a different domain name.

Instead of designing a new separate site for each domain, you may choose to use the content existing in your current domains. The following guide will assist you in duplicating a WordPress site.

Please be advised that the steps below may not be enough to successfully change your domain due to WordPress works with the server. Before you proceed, it is recommended that you generate a full backup of your website using the Backup feature of the cPanel.
Important Note:
HostGator is not accepting site clone requests at this time, and the steps below are only recommended if you are fully knowledgeable on how to work around your WordPress files. It is still strongly advised to contact your web developer and have them do this for you instead. The guide below can break your site if incorrectly executed, and HostGator will be unable to reverse the process for you.

Step 1: Copy Files/Content to the New Domain

Add the new domain into the cPanel's Addon Domains section, then complete the following steps to copy files to your new domain.

  1. From the cPanel, open File Manager.
  2. Open the public_html (or the document root of the domain where the source files are coming from).
  3. Click Select All found on top of the screen.
  4. Press the Ctrl key while clicking (un-selecting) the files/folders in your public_html folder:
    • cgi-bin
    • .qidb
    • addon domain directory
  5. Once the files are highlighted, click Copy in the top menu of the File Manager. A pop-up will open, showing the file path:
  6. Type the name of the addon domain directory to which you are copying the files. This box should now look similar to:

    *Replace youraddondomain.com with your actual new domain name.
  7. Click Copy File(s).

Step 2: Create A New MySQL Database

Once the files have been copied over to your addon domain directory, open the MySQL® Databases in the cPanel to create a new MySQL database.

Step 3: Modify the wp-config.php File for Your New WordPress Site

To edit the wp-config.php for WordPress:

  1. In cPanel, go to File Manager.
  2. Open the public_html and locate your addon domain directory.
  3. Right-click on the wp-config.php file and select Code Edit.
  4. A new page will open where you can edit the following information to reflect the values assigned to the new database, which was created in Step 2 ⤴.
    • DB_NAME
    • DB_USER
  5. Click Save Changes.

Your wp-config.php file should now reflect the correct database name, database user, and database password. This is essential for WordPress to know which database to obtain the information from.

Step 4: Export the Database

Export the database from the primary domain and import it into the newly created database. For help with this process, please refer to the following articles:

Step 5: Update the Database

The database settings must be updated to reflect the new domain name information.

  1. Go into cPanel > click on the phpMyAdmin icon.
  2. In the left navigation panel, click on the newly created database name.
  3. In the left navigation panel, click > wp_options.
  4. Click > Edit on the site URL line.
  5. Change the option_value to your new addon domain name or use a temporary URL if your addon domain is not pointed to HostGator yet.
  6. Click > Go.
  7. Do the same with the home URL line. Click Edit and paste in your addon domain or temporary URL (the same one you used in the site URL line).
  8. Click > Edit on the blog name line.
  9. Change the blog name to reflect your new blog.
  10. Click > Go.
  11. Click > Edit on the blog description line.
  12. Change the blog description to reflect your new blog.
  13. Click > Go.
  14. In the left navigation panel, click > wp_users.
  15. Click > Edit on theuser_login line > change the user name to reflect a new login username of your choice.
  16. On the user_nicename line, change it there as well. For security purposes, do not use Admin as either username.
  17. On the user_pass line, highlight and delete the characters already in that box.
  18. Create a password of your choice.
  19. To the left of that is the varchar(64) box.
  20. Click the down arrow and select MD5.
  21. Click > Go.
Test these changes by visiting http://youraddondomain.com/wp-login.php (replace youraddondomain.com with your actual domain name).

You should now be able to login to your newly imported blog.

Step 6: Update the Database Tables

Once the domain is working, and you can log in to the WordPress Dashboard of the new site, install the Search and Replace plugin. It will allow you to search all of the database tables, search for your old domain, and replace each instance with your new domain. You can uninstall the plugin after the tables have been updated.

In addition to the database, you should check your site for any links hardcoded into widgets, etc. Those links will need to be manually edited to reference your new site address.

For additional information on using this plugin, please review the following article:

Step 7: Update WordPress

  1. Log in to your WordPress Dashboard.
  2. In the left navigation menu, go to Settings.
  3. Click General.

Be sure that each of the following fields displays your new domain name and not the old one:

  • WordPress Address (URL)
  • Site Address (URL)