Should I use a Host-Named Site Collection (HNSC)?

New to Microsoft SharePoint 2013 (SP13) is “Host-Named Site Collections” (HNSC), replacing host-headers and offering an alternative to path-based site collection addressing (managed path – explicit or wildcard inclusion).

Microsoft encourage new SP13 deployments to create HNSC because they create a unique URL for each site collection, reducing URL length whilst allowing multiple URL’s to point to the same site collection with multiple claims-based authentication methods to the same web application. To read up more about HNSC see http://technet.microsoft.com/en-us/library/cc424952.aspx

Note: HNSC’s can only be created using PowerShell, i.e. there is NO configuration option in Central Admin. There are three PowerShell commands that are used for creating and managing HNSC’s:

  • Get-SPSiteURL – See all the URL’s and associated zones for a site collection.
  • Set-SPSiteURL – Add or amend a URL mapping for a site collection.
  • Remove-SPSiteURL – Remove a URL mapping from a site collection.

Here is a sample PowerShell script that creates a new host name http://finance.mycompany.com on the web application http://teams.mycompany.com

New-SPSite –Url http://finance.mycompany.com –OwnerAlias “mydomain\driscollm” –HostHeaderWebApplication http://teams.mycompany.com –Template STS#0

 

The Template “STS#0” above relates to the “Team Site” site collection template. To identify the site collection (web) template to use in the above PowerShell type in the following:

Get-SPWebTemplate

 

The results should appear similar to below:

References can also be found on the Web, for example see http://www.funwithsharepoint.com/Lists/Posts/Post.aspx?ID=2

To list the available site collection templates for a particular Web App you can also type the following PowerShell:

Get-SPWeb http://teams |   %{$_.GetAvailableWebTemplates(1033)} | select title, name

When the HNSC PowerShell script has successfully run, you will not initially be able to access the new site. This is because you next need to go to Internet Information Services (IIS) Manager, expand Sites and left-click to highlight the top-level web application site collection. Click Edit Bindings (right-side) and add the HNSC name (e.g. mycompany.com)  in the Host Name. Then in DNS Manager add a New Host (A or AAA) (e.g. finance.mycompany.com) to the associated forward lookup zone with the Port 80 IP address. Try entering the new HNSC name in the web browser – it should now connect successfully to the new site collection.