Is this possible to configure IIS7 to achieve the same functionality like Apache has regarding wildcard domains? I'm interested in routing user in ASP.NET web application based on subdomain user used in URL.
Something like is described here:
http://steinsoft.net/index.php?site=programming/articles/apachewildcarddomain
Thanks
A wildcard DNS record allows you to point all existing and non-existing subdomains to a specific area. For example, www.example.com and test.example.com would both direct to www.example.com when a wildcard subdomain is enabled. If your main domain is example.com, then the wildcard subdomain will be *.
Wildcard subdomain allows you to point all non-existing subdomains to a specific folder in your account. It means that if you enter different subdomains (which are not created in your cPanel) in your browser, they all will show the same content that you uploaded to the folder set for the wildcard subdomain.
The answer is No, IIS7 (still) does not support wildcard hostnames (see this). If you want to serve multiple domain on one website, the only workaround for now, as notandy suggested, is using a dedicated IP and doing it with DNS, which does support wildcards.
For completeness, IIS8 does not yet have this feature either.
Finally, IIS 10 in Windows 2016 supports wildcard subdomains.
Does IIS support wildcard host header? Can I capture and redirect *.mydomain.com to one web site?
The answer is Yes/No. Yes, because you are able to redirect *.mydomain.com to one web site. No, because the magic is in DNS and not IIS.
Here's how you do it:
At IIS MMC, configure a web site with NO host header, then assign an IP address to the site. (if you have one IP address in the box, then you can skip this). With this, the web site will bound to the specific IP and will listen to all HTTP requests send to the IP, and you are done :)
Next step is to make sure your name resolution works for the wildcard query and reply with the correct IP address. If you using Microsoft DNS service, it won't allow you to create a '*' A record (assuming you already created the domain zone in DNS MMC), you need to do the following:
%windir%\system32\dns\
* A IP.IP.IP.IP
Take note that by doing this, all * will response to the IP that you configured earlier. E.g. abc.mydomain.com, www.mydomain.com, K2k.mydomain.com and etc.
To verify that it is working, try ping utility ping (insert anything here).mydomain.com
and you should get replies from IP.IP.IP.IP
Then try browsing, http:// (insert anything here).mydomain.com/, you should get the same web page that you have configured.
Source
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