Disregarding the Apache and DNS setup and focusing on CakePHP, these
are my thought on the subject at the moment.

I too have the clientname.example.com setup and have so far copied my
app for each subdomain. This works great until I start patching and
bugfixing... I need to sync to a lot of folders without overwriting
client-specific configurations.

So one sleepless night I sumbled on a way to have one "app" for
multiple domain on the same server. The prerequisite is that I have
been a good guy and not embedded any config in any files but
bootstrap.php and database.php. (sure, routes and any other config file
can use the same technique.)

Instead of any config data in these files, all they do is include a
domain-specific file. I parse the domainname like this:

$appName = substr($_SERVER['SERVER_NAME'],
0,strpos($_SERVER['SERVER_NAME'],'.') );

This extracts the "first" part of the domainname. "demo" from
demo.example.com

I can now include a file using this string. For example:

require(CONFIGS .'domains'.DS.$appName.'_bootstrap.php');

I have not decided if I prefer the to have one folder with named files
of many named folders with just the one or two files in each.

Around this you can add any type of checking you like. I check that the
request is for my site and also that the file to include actually
exists.

( substr($_SERVER['SERVER_NAME'],
strpos($_SERVER['SERVER_NAME'],'.')+1) == 'fileshifter.se' )

The above checks that the root domain is my application domain.

That's it. pretty simple really but it makes a lot of difference. I
imagine this is sort of how 37signals do their hosting for the various
public ROR apps.

(I am about to start testing this technique properly but it should work
fine.)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to