I’m working on an EE site for a college. They want multiple subdomains - say http://www.college.edu, math.college.edu, compsci.college.edu - each to bring up unique pages. Much of the content is shared between them; it’s more of how the user sees the site’s introduction. Site management is also shared between the subdomains.
I’ve seen a few ways to make this happen in the wiki and elsewhere. I wanted to do this entirely inside EE, without using multiple root index.php files or editing the root index.php file. This is what I’ve done; I’m looking for feedback from those with more EE experience to point out potential problems with this or even to say it’s ok.
First, I added the subdomains to the server configuration, pointing to the same server path as www (basically a domain alias). So for the moment www, math, and compsci bring up the exact same home page.
Then I created a template group for each subdomain - www, math, compsci, etc, and built the index template for each group to appear as I’d like.
Then I created a template group called “subdomain_chooser” and made its index template the site’s home page.
I gave subdomain_chooser/index the right to run PHP on input, and used this as the template’s contents:
<?php
if ($_SERVER['HTTP_HOST'] == "math.college.edu")
{
echo '{embed="math/index"}';
}
elseif ($_SERVER['HTTP_HOST'] == "compsci.college.edu")
{
echo '{embed="compsci/index"}';
}
else
{
echo '{embed="www/index"}';
}
?>At least in simple testing (the site is still being built) everything works as expected.
There are some understood caveats which I am not concerned about:
-These are not multiple sites by my understanding, so the MSM isn’t needed here. Just unique entry points into the same set of content. And there will be a ton of subdomains.
-Security implications of running PHP inside a template. I’ll need to do this elsewhere too, for other reasons.
-Understanding that a handcrafted URL of http://www.college.edu/math/ would bring up the math “home” page. No problem.
-SEO or other implications of using multiple subdomains versus one large www. This decision was for marketing purposes and needs to happen.
Any thoughts on the above method to solve this problem?
Thanks,
Mitch