Transforming WordPress multisite installation back to a single instance

Following steps need to be executed in order to achive smooth transition from a multisite to a single WordPress website:

  1. Backup your database and your files in a safe and easy to access place in case anything goes sideways. Make sure to have copy of your .htaccess file.
  2. Check plugins activated across the network and take notes;
  3. Check the current users that have specific roles in the selected subsite. You’ll need to update those later;
  4. Comment out all multisite-specific constants in wp-config.php;
  5. Identify the site ID of the instance that you’d like to make a single WordPress setup;
  6. Change the db prefix of users and usermeta tables to match those of the subsite you’ve chosen;
  7. Change the db prefix in wp-config.php with the prefix of the subsite;
  8. Provide the right users administrator permissions for the site by editing/adding usermeta entry for each of the users. Entry should be with a key <prefix>capabilities and value a:1:{s:13:"administrator";s:1:"1";} in order to be an admin. Just in case you can provide a <prefix>user_level entry with value 10 as well. That’s for admins only, of course.
  9. Move files from the multisite directory (be it wp-content/files/<id>/ or wp-content/blogs.dir/<id>/files/ to wp-content/uploads. If you are using mv command, make sure that the directories you are moving don’t already exist in wp-content/uploads as this will interrupt your process and will not allow to move all the files. Hosting’s storage or inodes restriction could cause you even more headaches if you don’t plan well files migration and you copy them. I used this command: mv -f -u blogs.dir/<id>/files/* uploads/
  10. Activate plugins that were active earlier;
  11. Replace entries in db containing the old files address: wp search-replace 'blogs.dir/<id>/files' 'uploads' --skip-plugins --skip-themes --dry-run and separately wp search-replace '<subdirectory/old-domain>/files' '<subdirectory/old-domain>/wp-content/uploads' --skip-plugins --skip-themes --dry-run
  12. Replace entries in db containing the old domain/subdirectory: wp search-replace '<old-domain>' '<new-domain>' --skip-plugins --skip-themes --dry-run
  13. Create redirect rules for any queries to the old address so that they reach the new one:
    RewriteCond %{HTTP_HOST} ^<old-domain>$ [OR]
    RewriteCond %{HTTP_HOST} ^www.<old-domain>$
    RewriteRule ^<old-subdirectory>\/?(.)$ "https\:\/\/<new-domain-and-directory>\/$1" [R=301,L]
    RewriteRule ^files\/?(.)$ "https\:\/\/<new-domain-and-directory>\/wp-content\/uploads\/$1" [R=301,L]
  14. Check and fix any missing or broken images in widgets, logo, favicon or any other weird place that did not replace itself properly.
  15. Replace the old multisite .htaccess rewrite rules with the default WordPress rules.
  16. Cleanup the database from just any tables with prefixes, different than the one you need.


Leave a Reply

Your email address will not be published. Required fields are marked *