If you run a multi-site installation of WordPress, the thought of implementing a dramatic change that could impact every WordPress website on your network is enough to cause you grief. However, don’t dismay. The process for successfully changing the primary domain name is fairly simple.

Step 1: Point the new primary domain name

All domains on your WP multi-site network run through the primary domain name. In order to ensure that there is minimal down-time for your network, the new primary domain name should successfully point to the network prior to committing the switch. In order to do this, you will need to complete the following:

  1. Edit the DNS for the new primary domain name with the nameservers where your network is hosted via your registrar.
  2. Add the new primary domain to your hosting package through your hosting control panel, and point it to the installation path of your network.

If you have configured your network to work with subdomains, you will need to create a wildcard subdomain for the new primary domain.

Step 2: Backup your database

It goes without saying that backing up your database before surgically editing it is a good idea. You’ll need to export an SQL file. It is also a good idea to make an additional copy of the SQL file – one copy for editing, and the other for just in case you need to restore the network to it’s prior state.

Step 3: Edit your wp-config.php file

Around line 85 in the wp-config.php file is a reference to your old primary domain name. You’ll need to edit the domain to reflect the new primary domain.

define( 'DOMAIN_CURRENT_SITE', 'YourOldPrimaryDomain.com' );

Step 4: Edit your database

With your editable copy of your database, you’ll need to open the SQL file in a text editor (not an IDE). Using the Find & Replace function/tool in your text editor, you’ll need to find all instances of your old primary domain name (excluding “http://www.”), and replace all instances with the new primary domain name. Once complete, save the changes.

Step 5: Make the switch

Once you have confirmed that the DNS for the new primary domain name has fully propagated, it is time to commit the changes you’ve made to complete the switch.

  1. Upload the updated wp-config.php file via FTP if you haven’t done so already.
  2. Dump/drop all tables in your database.
  3. Restore your database by importing the edited SQL file

Final thoughts

You’ll likely need to make additional configurations to the settings for the new primary domain name in WordPress if the old and new primary domain names differ dramatically in concept (i.e. site name, titles, etc.).

Also, if you originally had an email address using the old primary domain that had been attached to a particular site within your network, assuming you want email routed through the new primary domain, you’ll need to create the mailboxes for all the usernames that were previously attached to the old domain. However, if you want to continue routing email through the old domain, you’ll have to update the address in the settings of each site.

Other than that, you’re done!

NOTE: Do not attempt if you are wary of or unfamiliar with modifying your database. Always, always, always backup your data. Use this technique at your own risk.

Tags: , , , , , , ,