WordPress Multiuser – sub sites not loading after changing root domain

Problem: By installing WP MU sub sites before adding your domain name to your main blog (root site), the sub sites will instantly break for your users. They will not see their website or be able to login to their WordPress admin.

Fix:

  • You’ll have to edit the database with PHPMyAdmin: wp-dbname->wp_blogs>go through each blog id that is already installed and change the domain to blogname.domainname.com.
  • The stylesheet, javascript and images (likely) broken so you’ll have to change the reference to it.
  • PHPMyAdmin>wp_2_options (whatever number the blog ID is)->table 1 (siteurl)->change URL directly.
  • PHPMyAdmin>wp_2_options (whatever number the blog ID is)->table 37 (home)->change URL directly.
  • PHPMyAdmin>wp_2_options (whatever number the blog ID is)->table 97 (fileupload_url)->change URL directly.
  • PHPMyAdmin>wp_2_options (whatever number the blog ID is)->table 111 (dashboard_widget_options)->change URL directly carefully!, this is a serialized data field, you must also change the preceeding s:42 (or whatever number) value to the length of the new URL. Tip: compare to the existing url length and add or subtract how much longer your new url is to make sure you have the right serialized length.
  • In my case, I’m using a slideshow wpcycle which was also broken, so I changed it’s serialized data for each image in the slide show. Tip: try this one image at a time and check your website to see if it came back, before changing all images in the slide show. PHPMyAdmin>wp_2_options (whatever number the blog ID is)->table 188 (wp_cycle_images)->change URL directly carefully!, this is a serialized data field, you must also change the preceeding s:42 (or whatever number) value to the length of the new URL. Tip: compare to the existing url length and add or subtract how much longer your new url is to make sure you have the right serialized length.
  • PHPMyAdmin>wp_2_posts (whatever number the blog ID is) ->table xx (every post that has an image – this is where you can fix wordpress broken images) (guid)->change URL directly. Do this repeatedly until you’ve fixed all posts with images.
  • PHPMyAdmin>wp_postmeta ->table xx (every one) (thumbnail) ->change URL directly
  • PHPMyAdmin>wp_usermeta ->table xx (one for each user/blog) (source_domain) ->change URL directly.
  • Optional (these won’t break the blog)
  • PHPMyAdmin>wp_users ->table xx (this is just the user’s listed URL) ->change URL directly.
  • PHPMyAdmin>wp_2_comments (whatever number the blog ID is) ->table xx (this is just the user’s comment author URL) ->change URL directly.

I did all the above to verify exactly what it takes to fix a WP MU database. If you setup your WP Multiuser network and used it even more before pointing a domain name to it, you may have more tables to fix like taxonomy, etc.

The point is: Don’t add sub sites until your main blog is sitting on exactly the URL for the future. If you have to change it, use a tool that does mass search and replace on your entire WordPress database honoring serialized data fields! This tool does it right: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/

Easier fix: Download the tool above, upload it via ftp to your root directory of WordPress (it also fixes Joomla and Drupal broken databases with old URLs in them), run the search and replace script in a browser, then be sure to delete it for security when you are done.

Avoidance of this problem: Point your domain name to your WP MU before installing sub sites, they will automatically work if you have your wildcard subdomain setup in your DNS. Click here to find out how: http://wordpresstips.googlethem.com/wordpress-multisite-wildcard-redirect-htaccess-example/.

 

Leave a comment