Why does defining MULTISITE true change the database connection in use

This sounds like an error with the URLs that are defined in the multisite DB and/or a .htaccess issue.

When changing a regular WP install from live to local for example, you can change the URLs by setting this in your wp-config:

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

However with multisite there are additional references to the URLs the multisite was set up on in the database. If on your local database you look in the tables wp_blogs, wp_site and wp_options there’ll be entrys for the live site in the database. You need to change these to your new local url. i.e. from livesite.com to localsite.com

  • In wp_blogs these are all the entries in the domain column
  • In wp_site this is the entry under the domain column
  • In wp_options this is the option_value corresponding to the option_name of siteurl and home

Alternatively for ease of setup and to minimise any changes to the database I would recommend that you keep the existing urls and just add a rule in your hosts file to root back to your local machine i.e. in your hosts have livesite.com root back to 127.0.0.1 that way your database doesn’t have to change. The downside to this is that you’ll have to remove the entry to view the live site and some people can find that confusing. So this is completely your choice.

You then need to ensure that your .htaccess has the correct setup for multisite and rewrites. Those settings can be found here depending on if you have a sub domain setup or a sub folder setup.

Finally you need to make sure that on your local setup you have the rewrite_module active and your headers_module active (or equivilent) on your local web server