Thursday, February 3, 2011

IIS 7 - Add bindings to existing site programatically

To add bindings to an existing site such as add new subdomain, all you have to do is use the AppCmd tool. You may create a bat file and have this command:

%windir%\system32\inetsrv\AppCmd set site / (yoursitename)/+[bindings.protocol='(protocoltouse)',bindingInformation='(ipaddress):(port):(hostheader)']

For example your IIS 7 is configured for with name as "markg" on site listing, and you wanted to add the subdomain "" at any IP to port 80, then you must have this command:

%windir%\system32\inetsrv\AppCmd set site / markg /+bindings.[protocol='http',bindingInformation='*']

No comments:

Post a Comment