Return to Snippet

Revision: 8931
at December 7, 2008 14:13 by jonhenshaw


Updated Code
// You can have multiple installations in one database if you give each a unique prefix

$domain_list = array();

// auto database name
$domain_list["yourdomain.com"] = "";\

$domain_name = preg_replace("/^www\./", "", $_SERVER["SERVER_NAME"]);

if (array_key_exists($domain_name, $domain_list))
{
	$table_prefix = $domain_list[$domain_name];
	if (!$table_prefix) { $table_prefix  = "wp_" . md5($domain_name); }
}
else
{
	print "Unknown error"; exit;
}

Revision: 8930
at December 7, 2008 14:13 by jonhenshaw


Updated Code
// You can have multiple installations in one database if you give each a unique prefix

$domain_list = array();

// auto database name
$domain_list["henshaw.me"] = "";
$domain_list["dadlife.org"] = "";
$domain_list["parentresource.com"] = "";

$domain_name = preg_replace("/^www\./", "", $_SERVER["SERVER_NAME"]);

if (array_key_exists($domain_name, $domain_list))
{
	$table_prefix = $domain_list[$domain_name];
	if (!$table_prefix) { $table_prefix  = "wp_" . md5($domain_name); }
}
else
{
	print "Unknown error"; exit;
}

Revision: 8929
at October 14, 2008 12:26 by jonhenshaw


Initial Code
// Replace This

$table_prefix = 'wp_';

// With This

switch ($_SERVER["SERVER_NAME"])
{
case "your-website.com": $table_prefix = 'wp_yourprefix'; break;
default: $table_prefix = "wp_" . md5($_SERVER["SERVER_NAME"]);
}

Initial URL
http://sitening.com/blog/how-to-easily-manage-multiple-wordpress-sites-with-one-database-and-one-code-base/

Initial Description
This is a simple but powerful tweak to the wp-config.php file that will make it easy to run multiple websites using one database and codebase. Simply change "yourdomain.com" with your domain and that's it. Repeat that line for new domains.

Initial Title
Manage Multiple WordPress Sites With One Database and One Code Base

Initial Tags
database, wordpress

Initial Language
PHP