Page 1 of 1

Multi-Host Site

Posted: Wed May 02, 2007 5:18 pm
by OasisGames
I spent all morning messing around with my httpd.conf for Apache, and finally got this working:
Link to a sample
Link to another sample
What is this?
It is a system that allows for multiple databases to use the same set of files.

How does it work?
Apache runs the following command at startup:

Code: Select all

AliasMatch /free/[^/]+/(.*) "XXXXXXX/htdocs/free_host/$1"
(Where XXXXXXX is the rest of my hosting directory)
When you visit [site]/free/[something]/, you are internally redirected to [site]/free_host/, while the address stays the same.
In my site's configuration file (config.php), I do the following:

Code: Select all

$prepa = substr($_SERVER['PHP_SELF'],6);
$prepb = substr($prepa,0,0 - strlen(stristr($prepa,'/')));
$conf_database = "free_" . $prepb;
The site then connects to $conf_database using other parameters defined before this.
The end result is that I can host multiple sites using the same set of files, but running off of different databases (all with the same prefix, for easy-of-use on the administration part)

Now, it's not finished yet. There are tons of things that need to be added (adding new sites, using a foreground image for a header defined in the sql database, things like that), but I just want to get some opinions on the overall idea of it.

Note: This is not about the CMS used, but rather the multi-hosting. Keep that in mind.


EDIT: This really didn't fit anywhere else, as it's the Apache set-up and final outcome that matter

Posted: Wed May 02, 2007 8:23 pm
by feyd
I don't see how this topic is "client-side" .. It's server configuration. Moved.