Host-Named Site Collection (HNSC) is actually a means to have a separate DNS for each site collection rather than having all the site collections follow the URL of the web application (path-based site collections).
Host-named site collections are the preferred method to deploy sites in SharePoint 2013 and many features (like Apps) are optimized for HNSC.
For instance if I want to create 3 site collections, I can now have dedicated URLS :
Microsoft recommends this by default and makes use of it in Office 365; as far as I know all site collections we create in Office 365 are Host-Named Site Collections (HSNC). It is fully tested by millions of customers every day : –)
- The main reason for that is that HNSC make your farm design simpler to design, to setup and to operate.
- Another reason is that since resources are not used to support multiple application pools and web applications, the farm will be more stable.
- …and another obvious reason is that since less/no custom code (that can potentially harm the farm) is used in SharePoint 2013, there is also less risk that a single application pool get corrupted. In O365, only Apps or sandbox code (deprecated) is tolerated.
A SharePoint 2013 KISS design (Keep it Simple, Stupid) today means : 1 farm, 1 web app, HNSC and 1 zone.
- 1 farm : I still have to find real projects where my custom needs several farms.
- 1 web app : even the MySites can be hosted with other SharePoint Sites
- 1 zone :You can implement multiple authentication providers on a single zone but you need at least the Windows Authentication (NTLM) provider on the default zone (for the crawler, more details later).
Host Name Site collections are hosted in web applications that don’t have host headers.
ok hands-on now :
Step 1. Create a hosting web application without any host header and preferably on port 80.
This means that we will now avoid host header binding in IIS and responsible for resolving the correct site for the address based upon the incoming request passed through IIS.You MUST avoid host header in the “host” web app.
Step 2. In this Web App, we have to create a “normal” site collection
Step 3. Create DNS entries
Let’s go to the DNS server and create a new A Host with the portal.contoso.com FQDN and pointing to the web front end
Step 4. Create the Host Named Site Collection http://portal.contoso.com
In SP2013, HSNC can only be created via the New-SPSite PowerShell command; the –HostHeaderWebApplication option specifies that we are creating an HSNC and provides the link to the corresponding webapplication.
Let’s type the following command:
Even if HNSC can only be created via PowerShell, they can be managed from Central Administration like other site collections. For instance, our newly created HSNC will show up in the Site Collection list (Central Admin) :
Step 5. Managed Path for HNSC
(we can add more HNSC like a HNSC for the Search center, another one for the MySites,…)
Creating Managed path for HNSC can be done with the New-SPManagedPath Powershell command.
Let’s type :
New-SPManagedPath ‘teams’ –Hostheader
New-SPManagedPath ‘projects’ –Hostheader
Step 6. Creating Hosted-Named Site Collections
let’s create our 2 site collections:
New-SPSite ‘http://portal.contoso.com/teams/SPGovernance’ -HostHeaderWebApplication ‘http://eurosp/’ -Name ‘SharePoint Governance team’ -Description ‘SP governance team’ -OwnerAlias ‘contoso\administrator’ -language 1033 -Template ‘STS#0’
New-SPSite ‘http://portal.contoso.com/projects/SPPoc’ -HostHeaderWebApplication ‘http://eurosp/’ -Name ‘SharePoint Proof of concept’ -Description ‘SharePoint Proof of concept’ -OwnerAlias ‘contoso\administrator’ -language 1033 -Template ‘STS#0’
Now, 3 important remarks :
- The maximum number of Managed paths for HNSC : 20 for the whole farm ! (yes only 20!)
- You cannot list HNSC with managed Path in Central Administration.
- The equivalent of alternate access mapping cannot be applied to HSNC with Managed path as described below
Step 7. URL Mapping and Hosted-Named Site Collections
if for instance, we want the url http://contosointranet to be mapped to an existing url like http://portal.contoso.com but in a different zone, we can use something similar to what Alternate Access mapping provides (but focused on Hosted-Named site collections) :
Here again, we need to rely on PowerShell :
Let’s create a contosointranet.contoso.com DNS entry
Since we are mentioning zones, don’t forget that the default zone url must be always used by the crawler (and with windows authentication, not claim authentication); this is not clearly documented in the TechNet except here. if you don’t do this you might face issues with the Query search results (operated from from other zones).