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 /site.name: (yoursitename)/+[bindings.protocol='(protocoltouse)',bindingInformation='(ipaddress):(port):(hostheader)']

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

%windir%\system32\inetsrv\AppCmd set site /site.name: markg /+bindings.[protocol='http',bindingInformation='*:80:me.markglibres.com']


No comments:

Post a Comment