Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Given a wordpress multisite network, with a main blog, and assuming all content has been moved on to that blog, how would one collapse the network back down into a standard wordpress non-network non-multisite install?

share|improve this question

migrated from stackoverflow.com Oct 3 '11 at 12:01

This question came from our site for professional and enthusiast programmers.

    
I found two helpful links below, this IS possible. I found helpful info here: wpmututorials.com/how-to/how-to-disable-multisite and here: wordpress.org/support/topic/… We'll see how it goes. –  user14616 Mar 27 '12 at 22:20
    
I think a better way to phrase it would be to extract a single site from a network. Collapsing a network back would only really work the main site not any that were created on it. –  sanchothefat Jan 3 '13 at 13:06

5 Answers 5

up vote 6 down vote accepted

I've gone through the steps to extract a site from a multisite install to a single instance now:

  1. Set up a clean copy of WP but don't install it
  2. Find the site ID
  3. Copy the files from blogs.dir/ID/files to the new WP uploads folder
  4. Copy the theme the site uses and any plugins it uses to the appropriate folders in the new wp-content folder
  5. Take a back up of the multisite database but only the tables for the target site and the users and usermeta tables using MySQL workbench or equivalent
  6. Restore the backup to a new database and change the table name prefixes so they are all the same eg. 'wp_SITEID_' to 'wp_'
  7. Using MySQL workbench or query browser tidy up the users and usermeta tables like so:
    1. DELETE FROM wp_usermeta WHERE user_id NOT IN( SELECT distinct(user_id) FROM wp_usermeta where meta_key LIKE 'wp_SITEID_%' );
    2. DELETE FROM wp_users WHERE ID NOT IN( SELECT distinct(user_id) FROM wp_usermeta where meta_key LIKE 'wp_SITEID_%' );
    3. UPDATE wp_usermeta SET meta_key = REPLACE( meta_key, 'wp_SITEID_', 'wp_' ) WHERE meta_key LIKE 'wp_SITEID_%';
    4. UPDATE wp_options SET option_name = REPLACE( option_name, 'wp_SITEID_', 'wp_' ) WHERE option_name LIKE 'wp_SITEID_%';
  8. Begin the WP install process to create a wp-config.php but don't click 'Run the install'
  9. Create a default .htaccess file if permalinks were in use or just visit the permalinks page in wp-admin
  10. You'll need to update any old URLs in your database next. Ideally use a safe search/replace tool like the one in wp-cli or its general purpose precursor search/replace db by interconnect/it. Specifically replace blogs.dir/SITE_ID/files with uploads, and if you're changing your site URL search for oldsite.com and replace with newsite.com.

A fair bit of effort and you have to be careful with the database edits but that's the only I can see to extract a single site from an existing multisite with all its settings etc... intact.

EDIT:

As spotted by @Jake I forgot to mention the final steps you may need to take eg. search/replace of old URLs. I've updated the list accordingly.

share|improve this answer
    
Nothing in step 7 worked or had any effect when I changed SITEID to the correct site id. Instead of that, you should mention that the siteurl and home options will likely need to be updated in the wp_options table. The rest of this was pretty good checklist. Thanks. –  Jake Dec 2 '13 at 3:31
    
Also will likely need to do a find and replace on the database for old domain / new domain if changing. And will almost DEFINITELY need to do find and replace for blogs.dir or uploads/sites to make sure any links to images/files are correct. Be careful though with all of the serialized data in WP. It isn't very safe to run an open find and replace in MYSQL. Use something like: interconnectit.com/products/… –  Jake Dec 2 '13 at 3:40
    
@Jake thanks, I forgot the context of changing the URL and you're right I missed the search/replace step for existing URLs, adding that in for the sake of completeness –  sanchothefat Dec 2 '13 at 15:35
    
@Jake I didn't go into detail but step 7 basically removes users that don't belong to the site you're extracting and makes sure they still have the correct permissions. It's a clean up task really. –  sanchothefat Dec 2 '13 at 15:45
    
I understood what they did, just the first couple returned errors for me, but maybe I was missing something, and I am not sure I had any users to clean up, so it was easy to skip anyway. And don't get me wrong, this was extremely helpful without that other stuff, just good to note for future use. Thanks! –  Jake Dec 2 '13 at 17:29

It is possible to remove the multisite install without reinstall a new blog. Follow steps.

  1. Create a backup, database dump and file backup of wp-content
  2. Set constant WP_ALLOW_MULTISITE in your wp-config.php to FALSE
  3. Remove or comment MU settings in wp-config.php, like this:

    /**
    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', false );
    $base = '/wordpress/';
    define( 'DOMAIN_CURRENT_SITE', 'localhost' );
    define( 'PATH_CURRENT_SITE', '/wordpress/' );
    define( 'SITE_ID_CURRENT_SITE', 1 );
    define( 'BLOG_ID_CURRENT_SITE', 1 );
    */
    
  4. Remove the MU settings from .htaccess, like the source below:

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
    
    # add a trailing slash to /wp-admin        
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    # END WordPress
    
  5. Create the permalinks new, in the backend wp-admin/options-permalink.php and maybe copy the result in .htaccess, if is not possible for WP, rights for write on this file.

  6. Remove un-usefull entries in table users; use the follow sql statement in a tool, like phpMyAdmin or Adminer

    `ALTER TABLE `wp_users` DROP `spam`, DROP `deleted`;`
    
  7. The follow tables can be dropped:

    • wp_blogs
    • wp_blog_versions
    • wp_registration_log
    • wp_signups
    • wp_site
    • wp_sitemeta
    • wp_sitecategories (only, if exist)

    (change wp_ to your database prefix)

  8. Now you have only the last tables of other blogs of the network. If you will use it also this content, then export this before via WordPress export as XML and import now in the clean single install.

share|improve this answer
    
This is a good answer, but, I've accepted the one by @sanchothefat as his can be used to extract any site regardless of ID, whereas your instructions would give me the root site –  Tom J Nowell Jan 3 '13 at 15:08

Actually it is possible and fairly easy to do; I've done it myself several times.

There are there things to consider.

  1. wp-config.php which defines if multi site or single site
  2. .htaccess which contains the rewrite rules to support multi site
  3. the additional tables created to support multi site

Commenting out the multi site define(?) in wp-config and updating your permalinks will revert the site to single site/default mode. Then all you have to do is clean up your database.

If for some reason you are not able to access your wp-admin to update the permalinks simply delete your .htaccess file. WordPress will recreate it for you in single site mode.

I'll do my best to find the link to the codes/support article and update the answer with it.

Here's a link to one item on the support forum http://wordpress.org/support/topic/revert-to-single-site

share|improve this answer

The basic processes here work well even in WP 3.5.1 One clarification: If you named your subsite something you'll have to change the links in the database to remove that name. If my subsite was named... mysite.com/comics then after following the above procedures your WP will look for mysite.com/comics and get errors on the permalinks. Edit the WP-OPTIONS table looking for the /comics extension and remove it. Also, check that the Uploads directory is pointing to the proper location - it may still show a blogs.dir entry and should now instead point to wp-content/uploads/

share|improve this answer
    
Can you please edit this to be a stand-alone answer. It looks like it might should be a comment on one of the other answers. –  s_ha_dum Mar 12 '13 at 21:29

It appears this is not possible.

The closest there is to this, is to set up a new Wordpress installation as a single site, and use the import/export to copy the content over.

share|improve this answer
2  
It is quite possible and fairly easy to do. –  Stephen Nov 6 '12 at 18:10
    
Keep in mind this is an old, old question, what may have been true back then may have been redone via recent advances –  Tom J Nowell Nov 7 '12 at 11:50
    
Of course you are right Tom, but that's simply not the case here. Perhaps I should have suggest an edit to the answer rather than a down vote. –  Stephen Nov 7 '12 at 23:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.