How to set up subdomains on IIS 7

asp.netIisIis 7Subdomain

asp.net Problem Overview


I have a website sitting on an IIS 7 server: WWW.example.COM

I would like to create several sub domains that looks like SUBDOMAIN1.example.COM

I created an IIS website and I set the bindings to be http, port 80, the ip address of my server, and SUBDOMAIN1.example.COM and the physical path to a folder under example.COM

I restarted my website and clicked on browse, the browser than opened with the address: http://SUBDOMAIN1.example.COM

But the website doesn't show up.

Do I have to do something with the DNS?

asp.net Solutions


Solution 1 - asp.net

This one drove me crazy... basically you need two things:

  1. Make sure your DNS is setup to point to your subdomain. This means to make sure you have an A Record in the DNS for your subdomain and point to the same IP.

  2. You must add an additional website in IIS 7 named subdomain.example.com

  • Sites > Add Website
  • Site Name: subdomain.example.com
  • Physical Path: select the subdomain directory
  • Binding: same ip as example.com
  • Host name: subdomain.example.com

Solution 2 - asp.net

Wildcard method: Add the following entry into your DNS server and change the domain and IP address accordingly.

*.example.com IN A 1.2.3.4

http://www.webmasterworld.com/microsoft_asp_net/3194877.htm

Solution 3 - asp.net

If your computer can't find the IP address associated with SUBDOMAIN1.example.COM, it will not find the site.

You need to either change your hosts file (so you can at least test things - this will be a local change, only available to yourself), or update DNS so the name will resolve correctly (so the rest of the world can see it).

Solution 4 - asp.net

As DotNetMensch said but you DO NOT need to add another site in IIS as this can also cause further problems and make things more complicated because you then have a website within a website so the file paths, masterpage paths and web.config paths may need changing. You just need to edit teh bindings of the existing site and add the new subdomain there.

So:

  1. Add sub-domain to DNS records. My host (RackSpace) uses a web portal to do this so you just log in and go to Network->Domains(DNS)->Actions->Create Zone, and enter your subdomain as mysubdomain.domain.com etc, leave the other settings as default

  2. Go to your domain in IIS, right-click->Edit Bindings->Add, and add your new subdomain leaving everything else the same e.g. mysubdomain.domain.com

You may need to wait 5-10 mins for the DNS records to update but that's all you need.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTal CohenView Question on Stackoverflow
Solution 1 - asp.netDotNetMenschView Answer on Stackoverflow
Solution 2 - asp.netM. SalahView Answer on Stackoverflow
Solution 3 - asp.netOdedView Answer on Stackoverflow
Solution 4 - asp.netDamoView Answer on Stackoverflow