Web development · 30 Aug 2014 · 3 min read
How to disable WordPress Multisite and go back to a single site
WordPress Multisite (a “network”) is useful when you really run many sites from one install. Often it was switched on for a plan that never happened, and now it just makes plugins, updates and hosting harder. You can turn it off and go back to a normal single site. The main site keeps its content; the other sites in the network don’t come with it, so save them first.
Before you start
- Take a full backup of the files and the database, and check you can restore it. This change edits
wp-config.phpand the server rewrite rules, and a mistake can take the site down. - Save the other sites. Each sub-site’s content lives in its own database tables (
wp_2_posts,wp_3_postsand so on). After you disable Multisite, WordPress only reads the main site’s tables (wp_posts). If you need a sub-site’s content, export it first from that site’s dashboard with Tools → Export, and import it later into a new site of its own. - Note your network-activated plugins under Network Admin → Plugins. They will show as inactive afterwards.
Do this on a staging copy first if you can.
Step 1: edit wp-config.php
Open wp-config.php in the site’s root folder. Find the Multisite block. It looks like this (your domain and values will differ):
define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
define( 'DOMAIN_CURRENT_SITE', 'example.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
Delete all of these lines. The quickest change that works is setting MULTISITE to false, but removing the block avoids confusion later. If there is a define( 'COOKIE_DOMAIN', ... ) or define( 'SUNRISE', ... ) line that was added for the network or for domain mapping, remove that too.
Step 2: restore the standard rewrite rules
Multisite uses its own rewrite rules. Put back the standard single-site ones.
Apache (.htaccess). Replace the block between # BEGIN WordPress and # END WordPress with:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
If WordPress is in a subfolder, change RewriteBase / and /index.php to include it, for example RewriteBase /blog/ and /blog/index.php.
Nginx. Remove the Multisite-specific rewrites from the server block and keep the standard rule:
location / {
try_files $uri $uri/ /index.php?$args;
}
Then reload Nginx.
Step 3: log in and check
Clear your browser cookies for the site (the network sets its own), then log in at /wp-admin/. The My Sites and Network Admin menus should be gone. Then:
- Reactivate plugins that were network-activated.
- Check user roles. A Super Admin who wasn’t also an Administrator on the main site may no longer have admin rights. Fix roles under Users.
- Re-save permalinks under Settings → Permalinks (just press Save).
- Check uploads. The main site’s media is usually still in
wp-content/uploads/. Sub-site media sits inwp-content/uploads/sites/<id>/and isn’t used any more.
Step 4: tidy the database (optional)
Once you are sure everything works, and with a backup in hand, you can remove what the network left behind:
- The network tables:
wp_blogs,wp_blogmeta,wp_site,wp_sitemeta,wp_signupsandwp_registration_log. - Each sub-site’s tables (
wp_2_*,wp_3_*and so on), if you exported what you needed.
Your table prefix may not be wp_; check $table_prefix in wp-config.php. Leaving these tables in place does no harm, so skip this step if you are unsure.
If something goes wrong
- “Error establishing a database connection” usually means a typo in
wp-config.php. Compare it with your backup. - Every page except the home page gives a 404: the rewrite rules are still the Multisite ones, or Apache isn’t reading
.htaccess. Re-check step 2. - A redirect loop at login: clear cookies and check that
siteurlandhomein thewp_optionstable are the address you expect.