INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

MultiBlog

How you can use one installation of WP to power multiple Blogs by jpadie
Posted: 28 Aug 08

this works for domain based blogs (blog1.domain.com, blog2.domain.com).  there are ways to make it work for directory based blogs too (www.domain.com/blog1, www.domain.com/blog2) but that is beyond the scope of this FAQ.

the hack (for a plain vanilla mysql installation) is to edit wp-config.php as follows:

CODE --> --> wp-config.php

...
//ADD THESE LINES BEFORE THE TABLE PREFIX (LINE 18)

//for multiblog aware installations...
$curBlog = $_SERVER['SERVER_NAME'];
//strip the www prefix
$curBlog = preg_replace ('/^\s*w*\./i', '', $curBlog);
//convert any illegal tablename characters
$curBlog = preg_replace ('/[^a-z0-9_]/i', '_', $curBlog);

//END ADDED LINES

//EDIT LINE 18 AS FOLLOWS
// You can have multiple installations in one database if you give each a unique prefix
$table_prefix  = 'wp_'.$curBlog .'_';   // Only numbers, letters, and underscores please!

the first time you go to the new domain pointing at this directory, you will be taken to the WP set up routing.

and that's it.  now you can run all your blogs off a single installation.  making it easy to upgrade, share themes and plugins etc.

one hazard to be aware of.  If you use different permalink structures in each blog you can get a situation where the blog that uses the default permalink structure is the only one that's accessible! the solution is one of the following:
  • go to one of your blogs using a pretty permalink structure and apply them again (save).  this will regenerate the mod_rewrite rules.  the default permalink structure should work fine with the rewrite rules pointing everything back to index.php
  • make your .htaccess file non-writable by WP.  This will just ensure that things don't change.
there are other solutions too: separate directories and symlinks etc, which would allow the permalink rules to work seamlessly.  this just seems the neatest to me!

Back to WordPress FAQ Index
Back to WordPress Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close