8

In effect I'm working on a SaaS application where I want to give subscribers their own subdomain to access their information (in code I will be pulling the first part of the subdomain for use as their account name), similar to how Basecamp et all work. For instance, a subscriber might have the URL acme.myapp.com. Since there could be hundreds of subscribers I can't simply add a different host header for each client.

Apache allows you to specify a wildcard (*) and will redirect acme.myapp.com to myapp.com, wherein I can perform my logic to retrieve the user's account name based on the subdomain. I'm not sure how to automatically do this with IIS (It's been a while since I've had to configure IIS for anything except a single website).

Also, is there any special provisions that I need to accomplish this? When my app is ready and I'm looking at hosting for it, will I need anything specific from the host that would limit my choices? I was also considering using Windows Azure to take advantage of the cloud - would I still be able to do this if I went with Azure as a hosting platform?

Wayne Molina
  • 895
  • 4
  • 13
  • 24

2 Answers2

5

As Joe mentioned you would do this more with DNS than IIS.

IIS does not have support for *.domain.com wildcard domains. Instead you would create a site in IIS that had no host headers, so would respond to all requests on that IP that were not picked up by other sites that did have host headers. You would then create your wildcard DNS entry to point to the IP of that site and your done.

Sam Cogan
  • 38,158
  • 6
  • 77
  • 113
  • So there is no way to "fake" it without having the domain setup and doing it with DNS? I'm asking because I would like to test the account part (e.g. that acme.myapp.xxx retrieves the account for Acme), but if I'm understanding right it means I cannot test this with IIS unless I purchase the domain and set up the IP address? – Wayne Molina Nov 15 '09 at 16:33
  • 2
    Well if your just wanting to test it, you could setup IIS, then put some entrys in your local HOST file for the subdomains you want to test, so they point to you IIS server, this will allow you to test them on your machine without purchasing the domain. – Sam Cogan Nov 15 '09 at 16:44
  • As long as you only have an application per port in your IIS. – Marc Climent Dec 01 '10 at 17:44
2

If I'm understanding you correctly, you could use DNS to do this. Assuming that myapp.com is your domain, then in your myapp.com DNS zone simply add a CNAME record (acme) that points to the A record for your web site (www.myapp.com). That will send them to your main web site, where your code will take over and redirect them to the appropriate application.

You could also use a DNS wildcard record (*) which will catch everyting, such as acme.myapp.com, joeschmoe.myapp.com, etc.

joeqwerty
  • 108,377
  • 6
  • 80
  • 171