MultiBlog – a bit further on…

well, i’ve spent an hour or so on trying to create multiBlog in the most simple manner possible. in some respects, with the new version of WordPress, the biggest sweat of maintaining multiple installations is lifted by being able to specify a separate directory for wp-content. but using this we can’t guarantee the workings of third party plugins.

in turns out that we can solve the multiBlog issue very very simply and with only two minor edits.

wp-content/db.php

define ('FQDB', FQDBDIR . SITE . '.sqlite'); //use the SITE constant as the file name

and wp-config.php

define('SITE', $_SERVER['SERVER_NAME']); //define SITE

and it’s that easy. really.

but …. and it’s a small but … all the blogs will need to use the same permalink structure (as permalinks are done via .htaccess some of the time and therefore php isn’t fired up by the time rewriting is done); or, perhaps better, is to use php based url rewriting – so called PATHINFO permalinks by prepending the permalink structure with index.php/. See the WP Codex for more info on permalink structures and here for a plugin that helps work out what’s going on with rewrite rules.

personally i haven’t managed to get PATHINFO permalinks working properly yet. i’m not sure whether it is the PDO plugin or the rewrite rules or that i’m just doing something talentless. I guess i could debug by using a mysql database and still achieving the multiblog element by changing the wp-config file like this

switch ($_SERVER['SERVER_NAME']){
 case 'blog1url': $table_prefix  = 'wp_blog1_'; break;
 case 'blog2url': $table_prefix  = 'wp_blog2_'; break;
}

3 Comments

BertrandBJuly 20th, 2008 at 5:21 pm

Well,
I made a very simple way to make multiblog with very few modification on wordpress. The idea is to have a directory by bog with index.php, wp-config.php and wp-content then to pass the path to wp-config with a session variable.
for the moment it seems to wotk fine with wp2.6 and basic themes. I got the idea reading http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
More details (but in french)
http://www.wordpress-fr.net/support/sujet-15623-autre-multiblog

BertrandBJuly 23rd, 2008 at 6:31 pm

Yo have better control in multiblog installation it would be fine to modify db.php with :
if(!defined(“PDODIR”)) define (“PDODIR”, ABSPATH.’/wp-content/pdo/’);
if(!defined(“FQDBDIR”)) define (‘FQDBDIR’, ABSPATH .’/wp-content/database/’);
if(!defined(‘FQDB’)) define (‘FQDB’, FQDBDIR .’MyBlog.sqlite’);
and then you can fix this parameters in wp-config.php

JustinJuly 24th, 2008 at 8:53 am

Bertrand
i took a look at your post (et j’habite Toulouse et parle bien le francais). i was aiming for a solution that did not require any separate directory structures and, I’m still not sure why this cannot be easily done. as per my other post, i need to dig more into the url rewriting code to see what’s going on. WP is such a pain to debug…

on your second comment: i don’t really understand what you’re saying. i was using $_SERVER['SERVER_NAME'] as it seemed to me that the distinction between blogs could be articulated through the url. however it does occur to me that this does not deal with separate blog urls like http://www.example.com/blog and http://www.example.com/blog1 etc. your solution handles this much more elegantly.

For me, I want all my blogs to be simply virtual hosts pointing at the same directory.

Leave a comment

Your comment