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

one installation, multiple blogs

one installation, multiple blogs

(OP)
and all without using WP MU...

the reality is that this hack is _very_ simple.  i'm surprised noone has documented it before.  This explanation is only for domain based blogs (i.e. blog1.domain.com, blog2.domain.com etc) rather than directory based blogs (www.domain.com/blog1, www.domain.com/blog2) but there is no difficulty in extending the principle.

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!

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!

RE: one installation, multiple blogs

(OP)
i have posted this as a FAQ as well...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

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