WordPress

How-to change the domain for my WordPress site

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.
    change wordpress domain url@2x
  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' --all-tables --dry-run
  5. If you are happy, remove ‘dry-run’ by running the command below.
    wp search-replace 'www.olddomain.com' 'www.newdomain.com' --all-tables

Was this guide helpful?

Need help with this?

Open a ticket and link to this guide so our team can see what you have tried.

View support tickets

Power your business with Ecenica Hosting

Built for WordPress and serious websites. Fast, secure and supported by real people in the UK.

Ecenica hosting services represented by a connected red route across London