Iis – Multiple domains (with & without www prefix) on same server, running the same code

domaindomain-name-systemiis

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.

Question

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

Best Answer

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).