Поделиться через


How to set a host header on the default website

Here is a quick tip, although not related to ASP.NET MVC. To set a host header for the default website in IIS you can use the following command, where vwdhost is your host name. This will cause two bindings to be added to the default website. The standard binding on port 80 without a host name and another binding on port 80 with 'vwdhost' as the host name. This way, you can still browse to https://localhost and now can browse to htto://vwdhost and likewise you can create new websites in Visual Studio as vdirs specifying localhost or vwdhost as the server as long as you have updated your hosts file with the new bindings. Note that this command sets your serverbindings rather than appends to them. I don't know of a command to simply append, although this would seem to be more useful. As far as I know, you would have to get the list of server bindings, and then set them along with your new server binding, kind of a pain.

D:\inetpub\AdminScripts\adsutil.vbs set w3svc/1/serverbindings ":80:" ":80:vwdhost"

Comments