jump to navigation

Multiple Blogs, One WordPress Install July 12, 2007

Posted by scoopseven in WordPress.
trackback

From http://likemind.co.uk/journal/?p=64

In the home directory for my new blog, I created an index.php like this, pointing to my existing blog directory:

<?
define(‘WP_USE_THEMES’, true);
require_once(‘../journal/wp-blog-header.php’);

In the same directory I created a .htaccess to route other requests to the existing blog:

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/portfolio$
RewriteRule . /portfolio/ [L,R=301]

RewriteCond %{REQUEST_URI} !^/portfolio/$
RewriteCond %{REQUEST_URI} !^/portfolio/index.php$
RewriteRule ^(.+) /journal/$1

Then I edited wp-config.php so it specified a different table prefix for my new blog, changing the assignment of $table_prefix to this:

if(substr($_SERVER['REQUEST_URI'], 0, 10) == ‘/portfolio’) {
$table_prefix = ‘pf_’;
} else {
$table_prefix = ‘wp_’;
}

At that point I requested the new blog and got the installation dialog. After following it my new blog was basically ready, except for its theme. I wanted to re-use most of the existing theme, so I simply edited the files to test the global $table_prefix wherever I wanted different output.

For just two blogs this approach is OK. I’d tidy it up before I added any more.

Comments»

No comments yet — be the first.