We've inherited the following website setup:

  1. one main website and around 130 secondary websites, which all point to the main website domain (through a CNAME DNS setup);
  2. Website is hosted on an IIS 6 server;
  3. The code is the same for all websites;
  4. The 130 secondary websites display almost the same content as the main website, with some unique differences, specific to each domain;
  5. The content is served based on the domain name. I mean, the backed reads the browser's web address and serves content accordingly.

The issue

Currently the 130 web domains don't work without www.

Attempted solution

Setting each of the 130 domains DNS with an A Name pointing to the IP address of the main website didn't work. This results in lost of the original domain, therefore the main website is served.


Is a purely DNS setup solution possible?

Is there a straight forward solution that doesn't require 131 versions of the same code and 131 different IP addresses?

I'm primarily a front end developer, all of this DNS/server setup is a bit out of my comfort zone so apologies if some of this description makes no sense and please let me know if you require further info. Thank you kindly in advance.

For the record (ah!), these are the DNS records allowed by our provider Star:

  1. A
  2. AAAA
  3. CNAME
  4. MX
  5. NS
  6. TXT
  7. SPF
  8. SRV
  • @zulkarnaen & 14theories the DNS provider is Star – user257991 Dec 10 '14 at 9:52

You need to configure both the DNS and web server. For example, for a "DOMAIN.tld" you need to configured the DNS zone to have both entries:

  • one A record for DOMAIN.tld
  • one A record for www.DOMAIN.tld (both pointing to the same IP address)

The web server needs to be configured to contain a (common) virtual web site for both DOMAIN.tld and www.DOMAIN.tld. For Apache HTTPD this means that one is the primary host (DOMAIN.tld) and the other is an alias (www.DOMAIN.tld).

  • Sorry but your explanation went way over my head. Do you mean that the domains should only contain 2 A records and no CNAME record at all? Do you mean we need to create a virtual website for each of the 130 domains (with and without www) manually? (We're using Microsoft's IIS 6 so I'm not sure how the Apache bit applies in this case.) – webDev Dec 9 '14 at 15:48
  • The OP notes that the web server is IIS, not Apache. – BE77Y Dec 10 '14 at 12:24
  • The problem here is that the root domain (ie. DOMAIN.tld) is a CNAME! Change this to an A record and you will be able to add an CNAME record for www.DOMAIN.tld. After all, it doesn't matter if it is IIS or Apache. – mteodor Dec 11 '14 at 16:54

how about to add new record on the DNS server,

for example your DNS Conf

sample.com        A     202.xxx.xxx.xxx
example.com       CNAME sample.com
www.example.com   CNAME sample.com

hope this help your issue :)

  • Is this really possible? I tried to add a second CNAME record but it appears to support only one CNAME per domain. – webDev Dec 9 '14 at 17:22
  • where you put the dns record?about cname – zulkarnaen Dec 9 '14 at 21:50

If your DNS provider has functionality to allow for a redirect "record", I think it would be the easiest way to set it up without having to create the aliases on the web server. Using the redirect record, redirect each of the root domains (myexample.com) to the www subdomain (www.myexample.com). Although this is not technically actually a pure DNS setup solution, I believe it will meet your needs as long as your DNS provider does offer this.

Who is your DNS provider?


I have this working with thousands of hostnames (subdomains). You probably want a wildcard DNS record (*.mydomain.com). You can use a CNAME record that aliases this to the A record for the main domain (even if the main domain matches the wildcard, like www.mydomain.com). The wildcard record will be used for ANY subdomains not explicitly found in other CNAME or A records, even those with multiple subdomains like www.sub1.sub2.mydomain.com. You could have explicit entries for each subdomain, but there is no reason to if they're all being handled by the same web server.

In IIS, you must bind the site to everything, or to an IP address (the public one, or the DMZ address your firewall forwards the public IP address to). Theoretically, you could bind each subdomains/domain name, but that would be a lot of bindings, and given the number you already have, you're probably adding more on a regular basis, so I would not recommend this.

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.