How to host multiple forums with one installation?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Starcraftmazter
Forum Commoner
Posts: 45
Joined: Mon Apr 24, 2006 11:36 pm

How to host multiple forums with one installation?

Post by Starcraftmazter »

Say you have 5 users with 5 separate databases, using the same phpbb install.
I know that can be done, but how?

I would assume, all you have to do is serve a slightly different config.php file based on some factor - eg. subdomain.

Can that be done using .htaccess, or how is it done?


Thanks.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Depends on the forum software.
Starcraftmazter
Forum Commoner
Posts: 45
Joined: Mon Apr 24, 2006 11:36 pm

Post by Starcraftmazter »

I believe I said phpbb.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Yes, sorry, you did.
You can use .htaccess and mod_rewrite to let apache execute the same scripts for different request paths.
Depending on the "real" path (stored somewhere in _SERVER, just take a look at print_r($_SERVER); ) you can e.g. inlucde different files in config.php
Starcraftmazter
Forum Commoner
Posts: 45
Joined: Mon Apr 24, 2006 11:36 pm

Post by Starcraftmazter »

Could you be more specific? I don't know much about .htaccess/mod_rewrite
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Let's say you have DOC_ROOT/boards/phpBB2
Now you can place a .htaccess in DOC_ROOT/boards with the contents

Code: Select all

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !^phpBB2/
RewriteRule   ^[^/]+/(.*)$  phpBB2/$1
For the request http://yourserver/board/userA/index.php %{SCRIPT_FILENAME} will contain userA/index.php (not boards/userA/index.php since the rule already is "located" in boards/)
The string does not start with phpBB2/ therefore the RewriteCond is matched and the RewriteRule is executed.
The RewriteRule cuts the first directory from the path and prepends phpBB2/ instead, userA/index.php -> phpBB2/index.php
The "real" request path should be available via $_SERVER['REQUEST_URI'] in config.php.

I've never done such a thing (except for a short test right now) and I'm not very familiar with phpBB. If you want to be on the safe side ask at http://www.phpbb.com/ . May even be there already is a ready-to-use mod for this.
Starcraftmazter
Forum Commoner
Posts: 45
Joined: Mon Apr 24, 2006 11:36 pm

Post by Starcraftmazter »

Alright, thanks!
Starcraftmazter
Forum Commoner
Posts: 45
Joined: Mon Apr 24, 2006 11:36 pm

Post by Starcraftmazter »

I have just tested this script, and it works!!!!

http://starcraftmazter.net/test/Insert_ ... /index.php

Thanks Volka, good job mate 8)
Post Reply