I’m working for a small web design firm and we are looking to implement a home brewed CMS to help manage our sites.
Currently we install our CMS in a separate folder under a unique user for each customer, then point their domain at that folder.
The difficult part with this is backporting important changes, for instance that async new google analytics code, or our improved way of preventing comment spam.
A couple of questions about a better way:
1: is it advisable to use the same backend code for every site we produce?
2: Assuming yes, what’s the best way? I’d though of checking $_SERVER[‘SERVER_NAME’] to determine which template, database connection etc to use.
Anyone any previous experience of doing this?
If they’re all hosted on the same physical server, you’d want
$_SERVER['HTTP_HOST'], which is the domain the user is requesting.SERVER_NAMEis the physical name of the server itself (which is set by Apache’sServerNamedirective).There’s no problem hosting multiple sites off the same code base, if they’re not too different from each other. If it’s just a matter of some branding and changing bit of text/graphcis here and there, no biggie. But if you’re doing fundamentally different sites, then your code will become an unmaintainable mess of “if servername is X then do this else do something else”.