Dirk Bergmann

Developer, panographer. Does consultancy work from own company. Lives in Chiang Mai, Thailand.


Chiang Mai

Hua Hin

Thailand Hotels

ListVote - List. Vote. Learn.

Partnerseek - Find Partners

Wildcard Host Header Binding And Subdomains with IIS7

Like its predecessors, IIS7 does not support wildcard (catch-all) binding or wildcards for host names, see this discussion for the state of things and how the much requested feature didn't make it into the II7 release version as it stands. So, if you try to add *.yourdomain.com as a host name in IIS 7 you will get this warning:

The specified host name is invalid. The valid characters are ...

There is only one "workaround" at the web server level and it requires a dedicated IP address for the particular site:

Set up a wildcard host record in DNS: right-click the zone yourdomain.com in DNS Manager>>New Host (A or AAAA)>>enter asterisk as wildcard and the dedicated IP address:

New Host for wildcard binding in DNS 

Then create you site in IIS without any host name:


This way DNS effectively takes care of the mapping of the URLs, throwing everything at the bound IP address which is pointing to your site. Here's hoping that IIS will someday catch up with Apache and allow more flexible wildcard mapping of host names.


Asteptals: ?????????? ?????????? ??? Wordpress 2.6.2, ????? ??? ????? ?? ??? dirk.net. ??????? ?????????)

Robert Rawlins: Thanks for writing this up, I've been looking into this today and find it so frustrating that despite what seems to be a large community backing for the feature M$ still haven't got around to building something in. Cheers, Rob

ps: But, you can do it at another level. Proceed as posted in the blog post, then use httpcfg.exe to restrict the binding to only the wildcard. It's a question of where you bind it.

Phillip H. Blanton: Not exactly. While not perfect, you can use a wildcard host header on one website on your IIS installation without the dedicated IP address. Refer to this image... http://content.screencast.com/users/pblanton/folders/Jing/media/12315692-57df-4413-ad47-1498daeca989/2011-03-01_0828.png I simply added '*' as the hostname on the main website on my server. Since host headers must be unique, you can only do this on one website. With your DNS set up correctly, any request to an unmapped subdomain, will be mapped to the main site. Go ahead and try it. Browse to http://boogerflicker.phasepoint.net. No, I don't have a DNS entry for boogerflicker.phasepoint.net. If you don't believe me. make up a different subdomain to phasepoint.net and give it a shot.

Patrick: You can flag the wildcard at your registrar, if they host your domains's dns, and leave the binding open on IIS. You don't need dns running on the server.

dirk: Hello reza, thanks for your comment. Apache has the wildcard bindings but IIS7 doesn't, and there might be reasons for this, and the reasons might be those you stated, security and "uncertainty" for clients, search engines etc. Google and other search engines certainly won't like this uncertainty and it will always better to create fixed DNS entries and host definitions if you can.

reza: hi thank you very much for your solution but , is there any security issue or traffic overhead problem with this method? if yes ? what should we do ? thanks again

Roman: Where a can found DNS Manager ?? THX

Lelala: hell, thanks a lot for pointing out to that issue - its really a PITA. (Especially if you do not wan't to use MS-DNS stuff) When will it be available out of the box? :-(

witsml: I've added a feature request here for wildcard hostheaders: https://connect.microsoft.com/WindowsServerFeedback/feedback/details/722874/wildcard-subdomain-hostheader-support-in-iis-7-5

Rohith VR: its useful for me...thank you for you kind informations

Chris Marisic: I merely left the hostname field blank when I setup the binding for https on IIS 8. Went to https://ssl.mysite.com and both firefox and chrome all said SSL was valid.