If you wish to change the primary domain of your WordPress multisite installation, you need to update five values in the website’s database. Before you proceed to follow the below steps, please ensure that you have secured full data backup at your end.
Following are the list of tables in which you need to update records:
- wp_options: lines named “siteurl” and “home”
- wp_sitemeta: the entry named “siteurl”
- wp_blogs: any entries in the “domains” column that have the old domain name
- wp_#_options: As every sub-site will have sets of tables that correspond to the blog_id in the wp_blogs table. You need to navigate to the wp_#_options table, where # corresponds to the blog_id, and update the “siteurl” and “home” values in the table.
Here we are considering that you have used wp_ as table prefix. If you have used different name, you will need to find appropriate tables.
You can use tool like phpMyAdmin to edit your table. Navigate to the necessary tables using phpMyAdmin or any other GUI tool, which are mentioned above and edit the URLs to the new domain you wish to set. Make sure that you are altering the URLs, exactly as they are.
You also need to comment out any predefined values in your wp-config.php file, as they will override the settings in the database. For example:
define( 'WP_HOME', 'http://domain.com' ); define( 'WP_SITEURL', 'http://domain.com' );
You will also need to update domain name in your wp-config.php:
define('WP_ALLOW_MULTISITE', true); define( 'MULTISITE', true ); define( 'SUBDOMAIN_INSTALL', true ); $base = '/'; define( 'DOMAIN_CURRENT_SITE', 'oldsite.com' ); define( 'PATH_CURRENT_SITE', '/' ); define( 'SITE_ID_CURRENT_SITE', 1 ); define( 'BLOG_ID_CURRENT_SITE', 1 );
You need to replace “oldsite.com” with your new website name.