Sunday, September 26, 2010

Wildcard domain problems with IIS 6.0/7.X

Today, when you want a wildcard domain to point to your site you need to do 2 things:
1) add a wildcard A record to your DNS:
   *.mydomian.com              188.188.2.97

2) add a wildcard entry to your IIS web site:
IIS control panel->right click on your web site-> properties->"web site" tab->advanced

Here you "Add" a site with en empty host header value.

This is the method to send all undefined host web server requests to this site.

For example:
if you have a few web sites defined in IIS (on the same web site node or an different nodes it doesn't matter) - for instance, foo.mydomain.com & bar.mydomain.com (these are defined with foo.mydomain.com, bar.mydomain.com host headers), when you define an additional 3rd value with an empty host header value on the same port, all other requests will go there (x.mydomain.com / www.x.mydomain.com / etc ...).
This is like defining one global wildcard per IIS instance.

This is the only way wildcards can be defined for your web site, and if you want to host multiple wildcard domains on the same IIS machine (e.g., *.mydomain.com and *.someotherdomain.com) you can't ! because the wildcard is a global one "*" and not part of a domain ("*.domain.com").

There are tricks to circumvent this problem ( ISAPI-Rewrite) but they are complicated , and microsoft IIS dev team are aware this is a problem (http://forums.iis.net/t/1095760.aspx), but they haven't provided this feature yet, not even in IIS 7.

There are even commercial products that were built to provide an answer to this problem.

One side note - in apache this is not a problem.

No comments:

Post a Comment

Feel free to comment. No links/URLs allowed in comments.