I think I have a weird/complicated situation but I think I'm overlooking something simple. We are setting up a Yii 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) whatever.theirsite.com (which is set up as a CNAME to portal.oursite.com - for advanced users)
2) portal.oursite.com/theircommunity - 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 portal.oursite.com/theircommunity, 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.
Valid example urls would be:
http://whatever.theirsite.com/mycontroller/myaction
http://portal.oursite.com/theircommunity/mycontroller/myaction
or for a module:
http://whatever.theirsite.com/mymodule/mycontroller/myaction
http://portal.oursite.com/theircommunity/mymodule/mycontroller/myaction
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.
Any advice?
Edit: One solution I thought of but haven't tested yet (not sure if it is a good idea or not, or if it would even work) would be to extend the URL manager to add new routing rules depending on which community is being asked for.
ex:
before application runs, do a db lookup to figure out which theme we are using.
if the theme uses a virtual root, then copy all existing url manager rules but append theircommunityname/ to the front of them.
Yes, I think your edit/URL manager setup is probably going to be your best option.
For what it's worth, those routing rules are going to look similar to the module routing rules, so you might be able to fake load a module that has the appropriate name using an app behavior. I did something similar for a client last year; it worked, but was complex. I would suggest your start getting comfortable writing unit tests against this system, you'll want them to make sure you don't break things in the future :-)