$uri = $_SERVER['REQUEST_URI'];
if (strpos($uri, '/blog1') === 0) {
define('DB_NAME', 'db_blog1');
}
else if (strpos($uri, '/blog2') === 0) {
define('DB_NAME', 'db_blog2');
}
else if (strpos($uri, '/blog3') === 0) {
define('DB_NAME', 'db_blog3');
}
Now when you visit http://example.com/blog1, WordPress will get the right database and, as luck would have it, that's all it needs. You still need to map http://example.com/blog1 to your master-blog/ directory though.
Alias /blog1 "/wherever/wherever/.../master-blog"
Alias /blog2 "/wherever/wherever/.../master-blog"
Alias /blog3 "/wherever/wherever/.../master-blog"
Apache's default httpd.conf comes with examples of using mod_alias if you have trouble finding the right place. Just search for "Alias" in httpd.conf. It'll be commented out and with instructions.
$ cd /wherever/wherever/...
$ ln -s master-blog blog1
$ ln -s master-blog blog2
$ ln -s master-blog blog3
The downside to this is that this is convoluted and not user-friendly and requires familiarity with the command line and PHP and a little bit about how Apache works.
<head>
blah blah blah
<?php
$uri = $_SERVER['REQUEST_URI'];
if (strpos($uri, '/blog1') === 0) {
echo '<link href='background-blog1.css' blah blah blah>'
}
else if (strpos($uri, '/blog2') === 0) {
echo '<link href='background-blog2.css' blah blah blah>'
}
else if (strpos($uri, '/blog3') === 0) {
echo '<link href='background-blog3.css' blah blah blah>'
}
?>
</head>
if category1
display picture1.jpg
else if category2
display picture2.jpg
else if category3
display picture3.jpg
else
display defaultpicture.jpgYou are not logged in, either login or create an account to post comments
posted by Solomon at 2:17 PM on January 30