Yes, you create a virtual host that answers all subdomain reqeusts. and Handle the behavior you just described in the application layer with a front-end controller. That is the way I did it. You can set up conditional rewrites but are you going to create a physical document root for each "dynamic site"? That would be a pain
What wait a minute...you can setup sub-domains using Apache? I thought that part of the domain resolution process was handled by DNS still?
Example: sub.domain.com
.com is looked up and the registrar is the asked to return the DNS servers at which point the hosts DNS servers lookup the domain...and then Apache can handle the request for sub-domains???
In the DNS you can setup specific subdomains, or you can set wildcards ( create an A record for *.domain.tld) then in apache you can set up rules to catch requests using various methods ( virtual hosts, mod_rewrite, etc.. ) and map them to different document roots, or resources ( other machines, etc.. )
When you define a serverAlias you can just define *.foo.domain.tld to catch only 2nd level subdomains under the 1st level subdomain "foo", passing requests to _anything_.bar.domain.tld to the next apache virtual host, which might catch *.domain.tld for example, or even *.tld I think... or maybe not ( either way which would be a security risk )
You could have apache handle mapping to other machines to handle different subdomains too, mod_proxy I think... but if different subdomains map to different machines it would be better to catch it at the DNS level. You could even write your own custom DNS server if you were so inclined, to allow pragmatic logic in the domain to resource mapping rules
Hockey wrote:What wait a minute...you can setup sub-domains using Apache? I thought that part of the domain resolution process was handled by DNS still?
Example: sub.domain.com
.com is looked up and the registrar is the asked to return the DNS servers at which point the hosts DNS servers lookup the domain...and then Apache can handle the request for sub-domains???
OK Interesting...up until now I've had to ask my host to add the sub-domain record...but I can just ask them to setup an A record using a wildcard and use VHosts?
Ideally I want to setup sub-domains programatically from my end and not have to request for sub-domains via email each time a client signs up for a service...
jshpro2 wrote:require no but recommended yes. you could even emulate it with 2 IPs on the same machine but you'd still be screwed if that 1 machine went offline
That's why it is also "recommended" that the 2 IPs are from different C-class subnets
There are 10 types of people in this world, those who understand binary and those who don't