Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to achieve something similar to what wordpress.com does - giving each user its own subdomain. user1.wordpress.com would in the VirtualHosts setup of Apache would have its DocRoot at /user/user1, for instance.

Now, our hosting service provider takes a fee for creating a domain, and in our case this would mean a ridiculous number of domains with a matching price. After some googling on DNS I came over a description of a DNAME record. That seems to fit the bill precisely. Any reason why my service provider would not do this, or why I should not do this?

share|improve this question
3  
If your hosting provider charges a fee for creating a subdomain (e.g. user1.mydomain.tld, the new domain being the user1 part), then switch hosting provider. It's almost a steal. –  gparent Jun 21 '12 at 14:32
add comment

1 Answer

up vote 4 down vote accepted

In my personal opinion, you need to switch hosting providers. If I understood you correctly, they are charging for subdomains which are otherwise completely free to create and use.

Anyway, no, there should be no additional cost for inserting this entry (other than the one they appear to charge). They only reason they wouldn't do this is so they can profit from the fact you cannot be bothered to get a better deal elsewhere. I do not know of a server setup that wouldn't support this very simple feature (that is, Apache and Bind support it out of the box).

How to do it:

A *.example.com record need not be a DNAME record specifically. What you essentially want is just a normal A record that points *.example.com to 1.2.3.4 (where the IP represents the shared IP the website is hosted on. If you're not sure what it is, just look at your example.com IN A record - it has to resolve to it):

*.example.com   IN   A  1.2.3.4

and then Apache will take it from there, just setup the VirtualHost to have the correct entry (I think it's ServerName) to be *.example.com and everything will match correctly (i.e. it'll load the correct DocumentRoot).

Just so you know: you cannot circumvent the fact that Apache will need to be (manually) configured. Some hosting providers may not do this, and if they don't, leave!

share|improve this answer
    
Then what is the difference between an A record and a DNAME record? From en.wikipedia.org/wiki/DNAME_record#DNAME_record I get the impression that there is 1:1 correspondance between an ip and a hostname, whereas a DNAME is like a CNAME, except that it can point to include multiple subdomains (such as *.bar.com). –  oligofren Jun 21 '12 at 14:39
    
The effect of them, in this case, would be the same. However, you should be aware that when a lookup is made for hello.example.com, it will DNAME to example.com - but this is still not an IP address. A futher DNS lookup will be made (analogous to resolving a CNAME) to convert example.com into its IP via the A record. This extra step is good if you only want to update a single record when you change IPs, but I think overall the overhead is not worth it if you only have 2 records (*.example.com. and example.com.). –  Jay Jun 21 '12 at 14:44
    
Aha, actually, I missed the point where DNAME refers to hostnames, whereas A records refers to ips. Thanks! –  oligofren Jun 21 '12 at 15:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.