Thursday, November 8, 2012

Implementing Host Named Site Collection



I am trying out this exercise in a Sharepoint 2010 instance. Login to the development server where you want to try out this demo.


1) Open Sharepoint Powershell and Run as Administrator

2) Create a new webapplication for Host Named Site Collection(HNSC) Demo.(using the below Powershell script)

New-SPWebApplication
cmdlet New-SPWebApplication at command pipeline position 1
Supply values for the following parameters:
Name: HNSCTest
ApplicationPool: Sharepoint - 1000

I am reusing an existing application pool here(Sharepoint - 1000).After the web application is created we will create the first Host Named Site collection.


3) Perform an IISRESET /noforce after this

4) Once this is completed,run the below command to create our first HNSC.

New-SPSite http://www.hnsctest1.com -OwnerAlias domain\administrator -HostHeaderWebApplication <Web application URL>

I am creating one more HNSC

New-SPSite http://www.hnsctest2.com -OwnerAlias domain\administrator -HostHeaderWebApplication <Web application URL>


You can ignore the below warning for the time being.

WARNING: The port specified for the new host header site does not match any known bindings in the specified Web Application.  The new site will not be accessible if the Web Application is not extended to an IIS Web Site serving this port.

5) After this browse to IIS Manager.Select the webapplication where you created the host named site collections(in our case,the webapplication name is HNSCTest)and right click -> Bindings -> Edit.



6) Enter www.hnsctest1.com for HostName and for 80 Port.Now make one more entry as 
             www.hnsctest2.com and 80.





















7) Now open the hosts  file in the location C:\Windows\System32\drivers\etc and edit it in Notepad.

8)To test this locally make the following entries in the file

127.0.0.1                       www.hnsctest1.com
127.0.0.1                       www.hnsctest2.com

9) Now open a new browser and type in the first HNSC http://www.hnsctest1.com

Note : If you are prompted for user name and password ,enter them.If it prompts again and the page doesn't open up, disableloop back security check on your machine.

10) Select the site template as required.I am selecting a Team Site template.Click OK.





Note : We are prompted to do this now as we didn't mention the site template while creation of the HNSC(in Powershell ).

11) Click OK in this screen too.



12)Do steps 9 to 12 for second HNSC http://www.hnsctest2.com

13):-) ......that was a successful implementation of Host Named Site Collection(HNSC).

1 comment:

  1. THANK YOU A LOT, MAN!
    U JUST SAVED MY TIME!!

    this host editing thing was my mistake,, i couldn't test my HNSC until I entered the records in the host files.. thank you again!

    ReplyDelete