WordPress – How to change/migrate domain name and site URL

If you’re migrating your WordPress site  to a new domain name (URL address) you’ll need to update the WordPress configuration.

The steps below detail the two ways two update WordPress when you’re changing domain names.

These steps are to be done after you configure the domain name to be accepted by your web server. If you are not sure if this has been done or do not know how to do this talk to your hosting provider.

Option 1: change domain names using wp-config.php

Please note, if you have the WordPress files in a sub-folder, for example domainname.com/wordpress but want users to access your site using domainname.com – you will need to set WP_HOME to the sub-folder and WP_SITEURL to the address for the website.

  1. Using FTP or your websites cPanel access, open the wp-config.php file in the root of your WordPress installation
  2. At the top of the file, below the <?php add the following code
  3. define('WP_HOME','http://domainname.com');
    define('WP_SITEURL','http://domainname.com');
  4. Replace ‘domainname.com’ with the new domain name for your website. You may also wish to add www. to the start to force WordPress to use www.
  5. WordPress-ChangeDomain2
  6. Save the changes and try accessing your site from the new domain name.
  7. If the site does not load, try the old domain name first then the new one.
  8. The WordPress site should now be using the new address.
  9. Don’t forget to redirect traffic from your old address to your new address.

Option 2: change domain names using wp-admin

Please note, if you have the WordPress files in a sub-folder, for example domainname.com/wordpress but want users to access your site using domainname.com – you will need to set WordPress Address (URL) to the sub-folder and WordPress Site (URL) to the address for the website.

  1. Log into your wp-admin
  2. Browse to ‘Settings’ -> ‘General’
  3. Under ‘WordPress Address (URL)’ and ‘Site Address (URL)’ enter the new domain name
  4. Save the changes and try accessing your site from the new domain name.
  5. The WordPress site should now be using the new address.

WordPress-ChangeDomain1

Was this article helpful?

Related Articles