I have a domain, with a number of CNAME records to

www.mydomain.com mail.mydomain.com ftp.mydomain.com

Now, what I would like to achieve is that if any other subdomain is queried or the domain itself is queried, I would like to have www.mydomain.com returned such that if

mydomain.com or inexistent.mydomain.com are queried, www.mydomain.com is returned by default.

I am not sure how this is possible if it is? Any help is appreciated.



for inexistent.mydomain.com just add

*.mydomain.com. CNAME www.mydomain.com.

But you can't CNAME mydomain.com as it's root of your zone. See here: https://stackoverflow.com/questions/655235/is-root-domain-cname-to-other-domain-allowed-by-dns-rfc

But you can create A record for mydomain.com, and have *.mydomain.com. CNAME mydomain.com.. In this case everything that ends with .mydomain.com would resolve to same ip.

  • 2
    Although, I'd recommend setting up the A record instead of the CNAME. e.g. *.example.com IN A It reduces the number of lookups made to the DNS server. – frogstarr78 Oct 22 '11 at 16:05
  • I am aware of that but I guess there's no other option since I am using a multi-site on a single IP setup using Apache VirtualHosts. – John Oct 22 '11 at 16:52
  • 2
    @John But what has a CNAME to do with Apache's VirtualHosts? Or better: Who told you that they only work with CNAMEs? – mailq Oct 22 '11 at 17:08
  • Can't get this done on godaddy... There's a limit of number of records in my zone file. But a wildcard record should count just as one no? – John Oct 22 '11 at 17:13
  • 1
    A CNAME and an A record will work exactly the same with respect to virtual hosts. The client will still follow the DNS to decide what address to connect to and will still set the host header to the original host it was looking for. – David Schwartz Oct 22 '11 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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