Wednesday, June 4, 2014

How to Create Host Named Site Collections in SharePoint 2013?

In short, Host-named site collections allows you to have unique URL addresses for each site collection. Say for e.g. Instead of having a typical "Sales" site URL as:, You can have it as and for HR, it can be and so on. As per Technet, HNSC as the preferred method for deploying site collections in SharePoint 2013. So, lets see how to create host named site collection in SharePoint 2013 using PowerShell.

Host named site collections can be managed only through PowerShell as of today!
Before heading into creating Host-named site collections, There are few Points to ponder:
  • All necessary DNS entries must be created prior creating HNSC (Which is obvious!) You can create a Foward lookup zone in DNS with wildcard entry pointing to the Load balancer or Web Server's IP.
  • The web application that houses host named site collection will be created without any host headers and listening to the default port 80. So the "Default web site" of IIS must be deleted first! Also make sure no other web app is using that port without host headers. If this can't be done for any reason, You have to manually add the host header entries in the bindings in IIS on every WFE.
Although, Its possible to create site collections with unique URLs by creating separate web applications in traditionally way, Remember there is a limit of 20 web applications per SharePoint farm!
create host named site collection in sharepoint 2013

Create Host-Named Site Collections Step-by-Step:

From the Domain Name System(DNS) perspective, path-based site collections share a common host name in a web application. Where as, each host-named site collections have a unique DNS host name and their own top-level URL. Here is how to create host named site collection in SharePoint 2013.

Step 1. Create hosting Web Application for Host Named site collections:
By default, the New-SPWebApplication cmdlet creates web application in windows classic mode authentication! make sure you are providing -AuthenticationProvider switch to make it on claims authentication mode.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set variables for New web application creation
$WebAppName = "HNSC Host Web Application"

#Variables for new Application Pool
$AppPoolName = "HNSC App Pool"
#Get the existing Managed Account
$AppPoolAccount = Get-SPManagedAccount "Crescent\SvcAppPool"
#To utilize existing AppPool, Use: Get-SPServiceApplicationPool <AppPoolName>

$ContentDatabase = "SP13_HNSC_Content"
$AuthProvider = New-SPAuthenticationProvider –UseWindowsIntegratedAuthentication

#Create the web application
$WebApp = New-SPWebApplication -ApplicationPool $AppPoolName -ApplicationPoolAccount $AppPoolAccount -Name $WebAppName -Port 82 -AuthenticationProvider $AuthProvider -DatabaseName $ContentDatabase -path "C:\inetpub\wwwroot\wss\VirtualDirectories\HNSCHost" #-URL http://G1WFE01

Step 2. Create Blank Root Site collection without templates:
The root site collection should be created without assigning any template to it. So, it will be a empty-blank site.
$ServerName = "http://G1WFE01"
New-SPSite -URL $ServerName -Name "HNSC Root" -OwnerAlias "Global\SvcOwner"
This site collection will be used for search crawl. The above two steps can be performed either by PowerShell or with Central Admin UI and they are one time activity. Once we have the host web application and blank root site collection ready, we can create any number of Host header site collections in it.

Step 3. Create host named site collection in SharePoint 2013 using PowerShell
SharePoint 2013 host named site collections can be created using PowerShell only. Here is the PowerShell script to create Host-named site collection. The -HostHeaderWebApplication switch identifies the web application where the site collection is to be created.
$HostURL = "http://WFE01"
$OwnerID = "Crescent\Support"
$OwnerMail= ""
$SiteURL = ""
$TemplateVal ="sts#0" #Team Site
#Create the HNSC
New-SPSite -url $SiteURL -HostHeaderWebApplication $HostURL -owneralias $OwnerID -owneremail $OwnerMail -Template $TemplateVal
That's all! We are done! The above script creates a host named site collection of Team site template. Hit the URL in browser and you should be able to access the site now!!

DNS for host named site collections: In DNS, either each of the HNSC URL should be configured as an A record pointing to the Load balanser IP or web server IP; or created as a wildcard DNS entry (* E.g.;, etc) so that anything ends with the particular domain name reaches the specific SharePoint farm.

Host-named site collections concepts are explained in my another article: Host Named Site Collections in SharePoint. Technet article for SharePoint 2013 host named site collections with SSL, Migrating path based site collections to Host-named site collection, etc.: SharePoint 2013 Host-named site collection architecture and deployment

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...