Consider the case of blogspot.com the domain is the one blogspot.com only but suppose i register in it with xxx then i will have xxx.blogspot.com like wise here it won't be the subdomain开发者_如何学编程 (i can smell) , but its some thing different ... how to achieve this ?? in j2ee web application..
- you need a DNS server that will resolve any subdomain as the adress of your server,
- you j2ee application can optain the hostname from the request header
UPDATE: here is a example of a BIND zone file:
$ttl 38400
mauriceperry.ch. IN SOA ks31441.kimsufi.com. maurice.mauriceperry.org. (
1237374933
10800
3600
604800
38400 )
mauriceperry.ch. IN NS ks31441.kimsufi.com.
mauriceperry.ch. IN NS ns.kimsufi.com.
* IN A 213.186.61.21
Here xxx.mauriceperry.ch will resolve to 213.186.61.21 whatever xxx is.
Buy a domain name at you're favorite ISP.
Configure for this domain a domain wildcard for the A record in the DNS zonefile (usualy using some nice tool from you're ISP):
* IN A 74.125.77.191
Code a Java Servlet (or whatever you are using) as front controller. The front controller will dispatch you to what ever the subdomain needs to show.
String domain = request.getLocalName(); String subdomain = domain.substring(0, domain.indexOf('.')); goto(subdomain); // or what ever you need for the subdomain
精彩评论