WordPress Multisite determine the correct domain to be set as current/default domain when setting multisite in Local fresh installation

I am unsuccessfully trying to setup multisite with WordPress’s fresh setup(WordPress installed in subfolder under htdocs of Localhost), but existing copy of Database already imported(provided by client).

Now the database already has atleast 15-16 different domain URLs already as entries of siteurl and home field in various wp_options tables for each site-domain.

And I want to use the same site-domains with little modifications to be able to work in Localhost WP multisite(like .com replaced with .local or so).

But even after doing all that and setting up multisite with following wp-config.php settings, when I try to access domain1.local, it tries to redirect to domain2.local like http://domain2.local/wp_signup.php?domain1.local and never redirects properly:

/* Multisite */
define('MULTISITE', true);
define('WP_ALLOW_MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'domain1.local');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);


RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*.php)$ $1 [L]
RewriteRule . index.php [L]

Can anyone help in figuring out what’s wrong here ?

Go to Source
Author: Vicky Dev