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.
You can create a subdomain, by creating a new folder on your web space. This folder should contain an index file, which is the page that will be displayed when accessing the subdomain. You can create an unlimited amount of subdomains. Add a folder to the root of your web space.
Subdomains are created to organize and navigate to different sections of your website. You can create multiple subdomains or child domains on your main domain. In this example, 'store' is the subdomain, 'yourwebsite' is the primary domain and '.com' is the top level domain (TLD).
via http://forums.asp.net/t/874598.aspx
If your DNS provider (ie. ISP) have "wildcard" option you could set *.mydomain.com -> myIP
Next step. Option #1 Make a script that creates 1 sites for each subdomain in IIS Option #2 Make a url_rewrite script that rewrites urls to correct folder on-the-fly.
option 2 is probably what you are looking for (and is STRONGLY recommended and preferred to option 1).
more info about url rewriting on iis7: http://learn.iis.net/page.aspx/460/using-url-rewrite-module/
The Microsoft URL Rewrite Module for IIS 7.0 provides flexible rules-based rewrite engine >that can be used to perform broad spectrum of URL manipulation tasks, including, but not >limited to:
- Enabling user friendly and search engine friendly URL with dynamic web applications;
- Rewriting URL’s based on HTTP headers and server variables;
- Web site content handling;
- Controlling access to web site content based on URL segments or request metadata.
the url rewriting option makes it easy to have hundreds of thousands of companies, their names can be read from the database and a url rewrite will handle the redirects. after that you can forget about it (for the most part) as it will keep on working for all the companies signing up in the future as well.
First, you have to configure your DNS server to resolve *.example.com to the IP of your server.
Then, you have two choices:
Generally, the better approach to this (if possible) is to not use Host Headers or separate IIS sites for each signup. Simply dedicate an IP address to that application that responds to all requests on Port 80 (or whatever port you use) and let your application detect the host header on request. This way, if you have 1,000 signups you don't end up with 1,000 "things" that need to be configured properly at the OS/services layer.
Alternatively if you just want the code, not sure what language you're looking at, but see below for C#...
http://forums.iis.net/t/1151463.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With