Multi-Host Site

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
OasisGames
Forum Commoner
Posts: 26
Joined: Mon Apr 23, 2007 3:24 pm
Location: Ohio

Multi-Host Site

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't see how this topic is "client-side" .. It's server configuration. Moved.
Post Reply