Forum Moderators: phranque

Message Too Old, No Replies

IIS: Wildcard subdomains

IIS: Wildcard subdomains

         

Einstein

5:12 pm on Mar 9, 2004 (gmt 0)

10+ Year Member



Hi

How can I configure IIS to accept any subdomain on a website?

It's not enough to redirect the user to a subfolder on a website. It has to accept all subdomains no matter what a user types. The subdomain is then handled by the application which will show the right content according to the subdomain.

An example would be:
If I typed test1.domainname.com I would see a webpage displaying "Welcome to test1" where test1 is read from the url. In other words, I need to be able to use the subdomain as a variable to show the right content and I don't want to add 5000+ enties to the IIS.

In the DNS I typed *.domainname.com and pointed it towards an IP, which works fine when I do a NSLOOKUP. But I can't get the IIS to accept the use of a wildcard as subdomain.

Is there a standard word to write as a wildcard in the IIS to accept all subdomains, like postmaster on a mailserver is all unused email addresses?

dataguy

3:19 am on Mar 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey Einstein, you figure this out yet? I've been looking for the same answer... Please let me know.

Zaphod Beeblebrox

12:03 pm on Mar 13, 2004 (gmt 0)

10+ Year Member



In ASP, something like this:


Dim arrTmp
arrTmp = Split(Request.ServerVariables("server_name"), ".")
Response.Write("Welcome to sub-domain " & arrTmp(0))

Einstein

12:20 pm on Mar 13, 2004 (gmt 0)

10+ Year Member



Thanks Zaphod, the vb code wasn't the problem.

Yes if figured the wildcard subdomain out. There are only two way.

1/ Set the hostheader blank in the IIS configuration. This options requires that you run your own IIS or can convince your ISP that your site should be their default site :)

2/ Install a URL rewriter/ISAPI filter on the server and design your site accordenly.

My only option now is to invest in a dedecated server and have it hosted somewhere. Thanks Microsoft :(

Zaphod Beeblebrox

1:06 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



I don't see what the problem is, then.

I have a dedicated server, with a defined domain name, but still any subdomain a user might enter shows up in server_name.

So, catching this in your default.asp will give you control over what happens next.

Einstein

6:20 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



Hi Zaphod

You properly inserted an empty (blank) hostheader in IIS'en along with your IP. But if you have multiple domains you can't use this method unless you have multiple IP's on your server. You can only have one empty hostheader per server.

However this wont work for people using hosting solutions, unless their ISP will give/sell them an IP.

I don't understand why MS hasn't made it work with wildcards like in their DNS, so it would be possible to type *.domain1.com and *.domain2.com on another website using the same IP.

dataguy

10:17 pm on Mar 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Einstein, I've done some research and have determined that there is no way to do this except through the default web site, which is how I was doing it.

All requests to IIS for a domain that is not found in the host header of any site will go to the default web site. The default web site can parse out the 3rd level name in ASP if you need it to.

Not quite as clean of a solution as I'd like, but it does work. Better have a dedicated server, your ISP surely won't let you set something up as the default web site in a shared environment.

Hope this helps!

Zaphod Beeblebrox

11:31 am on Mar 15, 2004 (gmt 0)

10+ Year Member



Hi Einstein,

you didn't really understand me, I'mn afraid. I have my own domain registered in IIS (but that's beside the point, really). I host 5 other domains on the same IP. Like the subdomains, my default.asp detects the server_name the user is looking for and redirects them to the appropriate page.

I even set it up so I can add new domains or subdomains in a database. One new record, and a new (sub-)domain is live.

Now, explain again why this wouldn't work for you?

Einstein

12:43 pm on Mar 15, 2004 (gmt 0)

10+ Year Member



Sorry Zaphod

I must have misunderstood you. How did you make the IIS accept a wildcard subdomain so you can administrate the subdomains by using a database? I don't want to type sub1.domain.com, sub2.domain.com, sub3.domain.com etc. into the ISS. The only solution I can find is having domain.com as the default domain on the server?

I know it can be done with an Apachi server for windows, but I can't make MS IIS do it.

Zaphod Beeblebrox

10:44 am on Mar 16, 2004 (gmt 0)

10+ Year Member



I just check whatever is in server_name. It gives you the domain they're looking for.

Keep in mind that each of these domains have the same IP-address, so when someone types www.domain1.com they arrive at the same destination as when they type www.domain2.com.

The same applies to someone typing mysubdomain.domain2.com. Just check server_name...