WordPressMU: changing domain names.
Unfortunately, changing domain names in WordPressMU is a manual process. It’s something I’ve come across often and have to look it up each time. Here’s what I did, so I don’t have to look it up again. Original idea from Boris Masis.
1. Drop and run this script in the root wpmu directory:
<?php
define('WP_INSTALLING', true);
require_once('wp-load.php');
$old_domain = 'olddomain.com';
$new_domain = 'newdomain.com';
$query = "UPDATE wp_site SET domain = '$new_domain' where domain = '$old_domain'";
$wpdb->query($query);
$query = "UPDATE wp_blogs SET domain = REPLACE(domain, '$old_domain', '$new_domain')";
$wpdb->query($query);
$querystr ="SHOW TABLES LIKE 'wp_%_options'";
$tables = $wpdb->get_results($querystr, ARRAY_N);
echo count($tables);
$query = "";
if ($tables){
foreach ($tables as $table){
$query = 'UPDATE '.$table[0]." SET option_value = REPLACE(option_value,'$old_domain','$new_domain')";
$wpdb->query($query);
}
}
?>
2. Edit wp-config.php and set “DOMAIN_CURRENT_SITE” to the appropriate domain.
That’s it, everything should work properly.