79

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?

jdecuyper
  • 3,934
  • 9
  • 39
  • 51
Tal Cohen
  • 1,043
  • 1
  • 8
  • 10

4 Answers4

119

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
jdphenix
  • 15,022
  • 3
  • 41
  • 74
DotNetMensch
  • 1,214
  • 1
  • 9
  • 3
8

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

M. Salah
  • 671
  • 7
  • 10
  • 2
    This, and then step 2) from @DotNetMensch for full setup if anyone wondered. – przemo_li Oct 10 '16 at 09:39
  • Works only if all sites are on the same server. In my case the www site is on one server and all subdomains are on another server – Qua285 Apr 07 '22 at 07:33
5

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

jdphenix
  • 15,022
  • 3
  • 41
  • 74
Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • I need this to happen at run time, so that clients can create their own sub domains. So the hosts file isn't a good solution for me. – Tal Cohen Nov 01 '10 at 21:50
  • And I can't wait until the dns server is updated, cause its has to happen right away. Now i tried to create a sub domain through plesk (cms) but it seems not to be working as well. I would have used the iis 7 rewrite tool to rewrite paths to my sub domains.. but if i do that, i'm not actually creating a website/virtual directory on the iis server and i cannot limit bandwidth for subdomain... – Tal Cohen Nov 01 '10 at 21:55
  • 12
    @Tal - subdomains and domains propagate through DNS, which takes time. These are fundamentals of how the Internet works. Perhaps you need to look at a different approach to whatever problem you are trying to solve. – Oded Nov 01 '10 at 22:10
0

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.

Damo
  • 361
  • 4
  • 16
  • @DotNetMensch said the opposite of what you are saying "you must have an additional website in IIS". A primary use case for subdomain would be to serve a separate site. You could get the same effect that you are proposing by not binding to a specific hostname. – cchamberlain Feb 24 '16 at 19:07
  • @Damo - struggling to understand this advice. Surely the point of a subdomain is to point towards its own content/application (e.g. forum.site.com). Your method just has the url land on the main site defined within the site path. Rather bad advice? – stigzler Feb 27 '21 at 22:49