IIS Express catch-all Subdomain url

2019-04-06 14:28发布

问题:

I'm looking for a solution for a subdomain catch-all url in IIS Express.

Basically, I've looked around and found how to create domains/subdomains in IIS Express.

It was quite easy to find, and all I had to do was add another binding in the ApplicationHost.config for IIS Express, and change my hosts file to point 127.0.0.1 to the domain.

This is the IIS express config file:

<binding protocol="http" bindingInformation="*:80:domain.com" />
<binding protocol="http" bindingInformation="*:80:sub.domain.com" />

However, I couldn't find any way to create a catch-all URL. There might have been an over-sight from me somewhere, I even tried (maybe naively) *:80:*.domain.com and *:80:*.

Another question that I've searched but couldn't an answer to is binding IIS express to a catch-all url completely (as in, every request should pass through IIS Express for a specific port).

If it matters I'm using an ASP.NET MVC 3 application.

回答1:

Unfortunately, I don't believe this is possible, because IIS does not support wildcard domains. The following sites detail potential workarounds.

http://forums.iis.net/t/1095760.aspx

https://serverfault.com/questions/165660/wildcard-subdomains-on-localhost-using-iis7

Wildcard subdomains in IIS7. Is it possible to make them like it is in Apache?

The following article explains how IIS bindings work. In relation to your second question, the article states:

The shortest possible binding is reserved for servers with a single IP and site, or if you wish to have a “catch-all” site when no other binding fits. This binding, which uses the IP wildcard and no host header, would be applied absolutely last when no other binding match could be found. In this case the binding will simply be:

http *:80:



回答2:

I'm not that familiar with IIS Express, but typically if you don't set a hostname field, then IIS will service all requests, for all domains on the default web site. So you would basically bind to 127.0.0.1:80 and that "catch" everything.

But like I said, i don't know if IIS Express works this way or not.