In this article we’ll explain how you can change the domain your WordPress website is using.

Before you start please ensure you have completed the following:

  1. Register your new domain name
  2. Add your domain to your Ecenica web hosting. See How-to add a Domain Alias

Steps to change the domain your WordPress website uses

  1. Login to your WordPress Dashboard
  2. From the left menu click Settings > General
  3. Change WordPress Address (URL) and Site Address (URL) to your new domain.
  4. Scroll down and click the blue Save Changes button.

How to use WP-CLI to update WordPress post content to use the new domain

  1. Log in to cPanel.
  2. Click Terminal
  3. Navigate to the directory your WordPress website is in. For example, for your primary domain it would be the public_html directory:
    cd public_html

    Addon domains would be under a different directory you chose when creating your addon domain.

    cd addondomain.com
  4. Run the following command. The ‘dry-run’ flag will not make changes.
    wp search-replace 'www.olddomain.com' 'www.newdomain.com' --dry-run
  5. If you are happy, remove ‘dry-run’ by running the command below.
    wp search-replace 'www.olddomain.com' 'www.newdomain.com'