Transferring a WordPress Multisite

I have run into the situation where I needed to transfer a WordPress Multisite twice now, My first experience was horrific, but it seems I have a better handle on this now.

Step 1: Back everything up

Should be pretty self-explanatory — back up your files and database in preparation to transfer. DO NOT copy the .htaccess and wp-config.php files, it’s better practice to set these up from scratch.

Step 2: Copy the files to your new server/location

Send over your files to the new location via FTP, SSH, SVN, whatever. Create your database and set up your wp-config.php file.

Step 3: Go through WordPress installation

Before you import your database, go through the steps to set up the WP site from a clean install. Go through the steps to setting up a WPMU. This way the code you need to stick into your .htaccess and wp-config.php files will have the proper rewrite rules, as well as DOMAIN_CURRENT_SITE and PATH_CURRENT_SITE definitions.

Step 4: Import your database

How that you have the vanilla WordPress Multisite install set up, go ahead and import your database into it’s new location. Now that we have the database imported, it’s time to alter some tables.

Step 5: Go into the database tables

Give into the following tables, and seek out your old domain. Replace all existing records of http://localhost/wordpress with http://mydomain.com

wp_blogs – this holds record of all your WPMU blogs. Alter the domain field(s).
wp_options – here do the normal alterations from home_url and site_url, as if you were transferring a regular WordPress website. If you have multiple blogs, you will need to go into wp_2_options, wp-3_options, etc.
wp_site – This defines the multisite domain and path. Change the domain here.
wp_sitemeta – Search for the meta key siteurl – change the domain.
wp_usermeta – Search for the meta key source_domain – change the domain.

Once you have completed this steps, you’re all set! Leave comments below if you experience any issues!

11 thoughts on “Transferring a WordPress Multisite”

  1. Also, here’s a script for the find/replace:

    ‘http://localhost/projects/otffeo’, ‘otffeo.zeitguysdev.com’ => ‘localhost/projects/otffeo’);

    $mysql_link = mysql_connect( ‘localhost’, ‘USER’, ‘PASS’ );
    if( ! $mysql_link) {
    die( ‘Could not connect: ‘ . mysql_error() );
    }

    $mysql_db = mysql_select_db( ‘DB_NAME’, $mysql_link );
    if(! $mysql_db ) {
    die( ‘Can\’t select database: ‘ . mysql_error() );
    }

    // Traverse all tables
    $tables_query = ‘SHOW TABLES’;
    $tables_result = mysql_query( $tables_query );
    while( $tables_rows = mysql_fetch_row( $tables_result ) ) {
    foreach( $tables_rows as $table ) {

    // Traverse all columns
    $columns_query = ‘SHOW COLUMNS FROM ‘ . $table;
    $columns_result = mysql_query( $columns_query );
    while( $columns_row = mysql_fetch_assoc( $columns_result ) ) {

    $column = $columns_row[‘Field’];
    $type = $columns_row[‘Type’];

    // Process only text-based columns
    if( strpos( $type, ‘char’ ) !== false || strpos( $type, ‘text’ ) !== false ) {
    // Process all replacements for the specific column
    foreach( $replace_array as $old_string => $new_string ) {
    $replace_query = ‘UPDATE ‘ . $table .
    ‘ SET ‘ . $column . ‘ = REPLACE(‘ . $column .
    ‘, \” . $old_string . ‘\’, \” . $new_string . ‘\’)’;
    mysql_query( $replace_query );
    }
    }
    }
    }
    }

    mysql_free_result( $columns_result );
    mysql_free_result( $tables_result );
    mysql_close( $mysql_link );

    echo ‘Done!’;

    The first array is a bunch of search/replace pairs; you can do multiples. Then be sure to replace USER, PASS and DB_NAME. Put this in wordpress root, run it, then delete it for security reasons!

  2. re this SQL enought to acomplish step 5?

    UPDATE wp_options SET option_value = REPLACE(option_value, ‘http://example.com’, ‘http://example2’) WHERE option_value NOT LIKE ‘%{%’;

    UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, ‘http://example.com’, ‘http://example2’) WHERE meta_value NOT LIKE ‘%{%’;

    UPDATE wp_posts SET guid = REPLACE(guid, ‘http://example.com’, ‘http://example2
    ‘);

  3. i have imported multi site wordpress site from another server to here http://autismwisdom.com/main/
    i have configured correctly according to ur post
    but still i cant able to open the site

    RewriteEngine On
    RewriteBase /
    RewriteCond %{QUERY_STRING} (^|\?|&)s2member_file_download\=.+ [OR]
    RewriteCond %{QUERY_STRING} (^|\?|&)no-gzip\=1
    RewriteRule .* – [E=no-gzip:1]

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]

    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]

    php_value suhosin.simulation 1

    define(‘MULTISITE’, true);
    define(‘SUBDOMAIN_INSTALL’, false);
    define(‘DOMAIN_CURRENT_SITE’, ‘autismwisdom.com/main’);
    define(‘PATH_CURRENT_SITE’, ‘/’);
    define(‘SITE_ID_CURRENT_SITE’, 1);
    define(‘BLOG_ID_CURRENT_SITE’, 1);
    define(‘BP_ENABLE_MULTIBLOG’, true);

    1. Hi Raj,

      I think I can see the issue. In your database, you need to separate the domain from the path. In the copied content from wp-config.php, you have

      define(‘DOMAIN_CURRENT_SITE’, ‘autismwisdom.com/main’);
      define(‘PATH_CURRENT_SITE’, ‘/’);

      This should read

      define(‘DOMAIN_CURRENT_SITE’, ‘autismwisdom.com’);
      define(‘PATH_CURRENT_SITE’, ‘/main/’);

      Any subdirectory structure goes into the PATH portion. This rule is the same inside the WordPress tables, like wp_blogs, wp_sites, etc. Make this alteration and your Database issues should disappear.

      Also be aware of whether you are using trailing slashes (‘/main’ vs. ‘/main/’). You need to be consistent throughout all the locations of the URL, so I stick with ALWAYS having the trailing slash.

      Good luck.

Leave a Reply

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