So here was my situation – I wanted to have a subdomain off of my main site, but I didn’t want to have to create a whole new docroot with an entire new Solar framework application in it. Besides being “yet another install” of the same sort of thing, it would also be a pain to keep up more than one codebase that does a lot of the same things.
This got me to thinking that there had to be a way to convince Solar that it could use the same code with the subdomain without issue. Sure enough, it could – and it was actually really easy. Here’s my situation:
I wanted to have the main domain’s stuff still work (www.mydomain.com) just like it always has but I wanted the subdomain to point to one controller out of the main application (in this case, the Solar_App_Foo controller) when the subdomain was called (foo.mydomain.com). Solar makes it dead simple – it’s just a change in your config file.
Since it’s PHP driven, you can do fun things like checking to see what the value of $_SERVER['HTTP_HOST'] is right there in the definition:
$act=($_SERVER['HTTP_HOST']=='foo.mydomain.com') ? 'foo' : 'index'; $config['Solar_Controller_Front']['default']=$act
That’s all there is to it – the ternary check looks for the subdomain and sets the default controller to our Solar_App_Foo instead of the Index the rest of the site calls. And, since it’s just part of the same site, all of the links and other functionality work just fine. Plus no extra code to maintain!