Multiple Blogs with One Database and One Code Base
-
SiteNing has put up an elegant solution to an old WP challenge…
How to Easily Manage Multiple WordPress Sites With One Database and One Code BaseSeems easy enough, but I’m hung up on how to point the domains to the central code base. Can you help?
Assuming a server setup of:
/home/domain1.com/html/
/home/domain2.com/html/
/home/domain3.com/html/
/home/wordpress/[central wordpress code base]How would you configure the domain1.com to point to /home/wordpress/ directory?
My first guess was to simply add the full “new” path to wp-blog-header.php in /home/domain1.com/html/index.php like so.
require('/home/wordpress/html/wp-blog-header.php');
But while this connects to the database fine, it does not reference any of the files correctly. For example, it looks for the css file at domain1.com/wp-content/themes/default/style.css which obviously doesn’t exist.
Any help? Thanks in advance.
—
Here’s how Sitening recommends configuring the rest:Essentially you replace this line in the wp-config:
$table_prefix = 'wp_';
with this:
// 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; }
- The topic ‘Multiple Blogs with One Database and One Code Base’ is closed to new replies.