Wednesday, October 2, 2013

IIS 7 - Setting up host headers using command line or batch file

As part of windows server administration, administrators may face a common problem in transferring the host headers when migrating web applications from one server to another.

A simple solution is to prepare a list of host headers and execute the addition of these host headers via a command line

Step 1: Go to C:\Windows\System32\Inetsrv

Step 2:

a) Execute the command to a "Site Host header" appcmd set site /site.name:"Website name on IIS Server" /+bindings.[protocol='http',bindingInformation='*:80:Site Host Header']

b) For specific IP binding appcmd set site /site.name:"Website name on IIS Server" /+bindings.[protocol='https',bindingInformation='10.0.0.10:80:sampledomain.com']

c) For HTTPS binding appcmd set site /site.name:"Website name on IIS Server" /+bindings.[protocol='https',bindingInformation='*:443:Site Host Header']