creating sub-domains on signup

iis-7, registration, subdomain

Solution

First, you have to configure your DNS server to resolve *.example.com to the IP of your server.

Then, you have two choices:

- Every time a new account is created, you add its host to the configuration of IIS, so it is bound to a directory. I'm not sure how to do this programmatically.

- Every time a request is made to the server, you check the host, and redirect the client to the site corresponding to the host. It can either be an explicit redirect (the client arrives on http://businessname.domain.com/ and is redirected to http://sites.example.com/businessname/ ) or implicit (the client arrives on http://businessname.example.com/ and internally, the application located on a directory dedicated to businessname and treats the request.

Problem

I'm building a site where businesses will be able to sign-up for there own account which should be located at http://businessname.example.com with the "businessname" changing each time. I want to do this on a windows server (IIS 7) but am not sure how a go about it.

Original source