Feed on
Posts
Comments

I couldn’t find a clean way to support multiple WordPress blogs under a single site domain name, all using a single installation of the WordPress application. So, I came up with my own. :)

Debian does a decent job of it, if every blog has its own hostname, e.g.

  • http://www.ajmani.org
  • http://curtis.ajmani.org

But as soon as you want to do a second, separate blog underneath an existing one it all falls down. For example:

  • http://www.ajmani.org/sub_blog

You can copy all the WordPress php files into the new blog directory, as outlined here, but then you lose all the advantages of Debian’s package management and centralization of the application.

My solution was to hack up the /etc/wordpress/wp-config.php file. The default Debian file looks something like:


/** WordPress's Debianised default master config file
Please do NOT edit and read about how the configuration
works in the README.Debian
**/
require_once('/etc/wordpress/config-'.strtolower($_SERVER['HTTP_HOST']).'.php');
define('ABSPATH', '/usr/share/wordpress/');
require_once(ABSPATH.'wp-settings.php');

I edited it to conditionally search for a pattern that matches the sub_blog string. This string needs to be unique of course, and specific to each sub_blog installation.


/** WordPress's Debianised default master config file
Please do NOT edit and read about how the configuration works in the README.Debi
an
**/
if ( strpos($_SERVER['PHP_SELF'], '/sub_blog/') !== false ) {
require_once('/etc/wordpress/config-subblog.ajmani.org.php');
}
else {
require_once('/etc/wordpress/config-'.strtolower($_SERVER['HTTP_HOST']).
'.php');
}
define('ABSPATH', '/usr/share/wordpress/');
require_once(ABSPATH.'wp-settings.php');

I will have to update the /etc/wordpress/wp-config.php file after each Debian update to WordPress, but at least everything else is centralized.

A simpler option, if starting from scratch, would appear to be WordPressMU (Multi User). Since I had a bunch of existing blogs, I didn’t feel like trying to retro-fit them into a new install.

One Response to “WordPress & multiple blogs on one site”

  1. on 06 Dec 2006 at 9:12 am Curtis

    Cool! Thanks for doing that for us!

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.