Virtual Document Root For Many Community Sites

I think I have a weird/complicated situation but I think I’m overlooking something simple. We are setting up an application that will host other “skins” people set up. It’s basically one big community but on many different sites. Everything will be handled by one single common core Yii application.

Our plan is to allow two different URL configurations depending on what the skin owner wants to do:

  1. (which is set up as a CNAME to - for advanced users)

  2. - for those who just want it to work with no other configuration

In the first case, it’s easy enough to pick out the SERVER_NAME variable, look up the correct theme in the database, and serve up the correct theme/community. I have actually done this in the past and it works fine. However, I’m a little lost on the second case. I can still do the db lookup to find out what theme to serve from, but all the routing gets screwed up because theircommunity is not a controller. It’s more like a virtual directory but its dynamic. I feel like I’m missing a simple htaccess or possibly a UrlManager rule. Any advice?


Valid example urls would be:

or for a module:

In all cases, both pairs of requests need to go to the same place. Backend processing ensures that they look different but are handled by the same code.