Changing the Domain Name in WordPress Multisite

Introduction

This document explains how to update the site URL when moving a WordPress Multisite installation from an old domain to a new domain. The process includes updating the primary domain in wp-config.php and replacing the old domain references in the WordPress database.

Prerequisites

Ensure you have a complete backup of the WordPress files and database. Ensure you have access to the WordPress server wp-config.php. Ensure you have MySQL/phpMyAdmin access with appropriate database permissions. Confirm that the new domain is configured and pointing to the correct server. Identify the correct WordPress database and table prefixes before running SQL queries. Verify the old and new domain names carefully before performing the replacement. If the site uses SSL, ensure the new domain has a valid SSL certificate.

Implementation

In this post, we will explain how to change the site URL on the newly moved domain.

Step 1: Open the wp-config.php and edit define(‘DOMAIN_CURRENT_SITE’, ‘newdomain.com’);

define('WP_DEBUG', false);
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'newdomain.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Step 2: Open MySQL or phpMyAdmin and run the following query.

UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE tmp6d400b_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');

UPDATE tmp6d400b_posts SET post_content = replace(post_content, 'http://olddomain.com', http://newdomain.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://olddomain.com','http://newdomain.com');

UPDATE wp_site domain='http://newdomain.com' where id=value

UPDATE wp_blogs SET domain='http://newdomain.com' WHERE blog_id=value;

Conclusion

After updating wp-config.php and the required database entries, the WordPress Multisite installation will use the new domain. Clear the WordPress/server cache and verify the main site, network admin, and individual sites to ensure they are loading correctly. It is recommended to test all site URLs and functionality after the domain migration.

FAQs

1. Why do we need to update DOMAIN_CURRENT_SITE?
It tells WordPress Multisite the primary domain used by the network.

2. Why should we take a database backup first?
The SQL queries modify multiple database tables. A backup allows the database to be restored if an incorrect replacement is performed.

3. Do I need to update the domain in the database?
Yes. WordPress Multisite stores domain information in several tables, including wp_site, wp_blogs, and site-specific tables.

WordPress Multisite Setup and Domain Mapping

Talk to our experts:

Looking for the right technology solution for your business?. Our experts can help with web hosting, domain registration, DevOps and cloud, software development, web applications, mobile applications, and enterprise solutions. Get in touch with our team here.

admin

Our team has expertise across software and web development, WordPress, e-commerce, mobile applications, UI/UX, cloud and infrastructure, DevOps, CI/CD, API integration, security, testing, automation, and technical support. The team also works with AI-based software solutions, LLMs, AI workflows, AI agents, and intelligent application development to help businesses automate processes and build smarter digital solutions. We focus on developing, deploying, maintaining, and optimising secure, scalable, and reliable technology solutions while helping businesses adopt modern technologies and drive digital transformation.

Leave a Reply

Scroll to Top