Share via


Host named site collections in SharePoint 2013 Step by Step

Host Named site collections have now been the “recommended” approach, very much to the fact that SharePoint Online/Office 365 uses it and it is now the most tested (by Microsoft) method. 

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).

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).

Step 1. Create a hosting web application.

Step 2.Create a Site Collection .

Step 3. DNS and Find New A Host ...

Step 4. Create Host Name Site Collection.

Step5. For Host Name Site Colection use only Powersehll .

** PowerShell command: –HostHeaderWebApplication **

To create a web application for host-named site collections

  • The securityadmin fixed server role on the SQL Server instance.
  • The db_owner fixed database role on all databases that are to be updated.

**Example : **

########### Start Example #############

Add-pssnapin Microsoft.SharePoint.Powershell

# Parameters

$webAppHostHeader = 'http//portal.contoso.com'

$webAppName = 'Portal WebApp'

$siteTemplate = 'BLANKINTERNET#0'

$rootsiteTemplate = 'STS#0'
$AppPoolName= 'Host_Header_Name_Pool'

$AppPoolAccount='Contoso\sp_admin'

#DataBase Name

$DatabaseServer = 'sqltest' 

$DatabaseName  = 'WSS_HOST_Header_Site'

#Create Authentication Provider 

$sp= New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication

#Create a New Web Application and Applicaton Pool

$AppPool=New-SPServiceApplicationPool -Name $AppPoolName -Account $AppPoolAccount

#Create a New Web Application and Applicaton Pool

New-SPWebApplication -Name $webAppName -HostHeader 'portal.contoso.com'  -port 80 -ApplicationPool $AppPoolName -ApplicationPoolAccount $AppPoolAccount -AuthenticationProvider $sp -DatabaseServer $DatabaseServer -DatabaseName $DatabaseName

#A root site collection is a requirement for any Web application. It is also necessary for crawling content.

#Create a rool site collection

New-SPSite 'http://portal.contoso.com' -Name 'Portal' -Description 'Portal on root' -OwnerAlias 'contoso\administrator' -language 1033 -Template 'STS#0'

# ***IIS Binding***--------must IIS Binding and iisreset then use next steps....

#Create a intranet site collection

New-SPSite 'http://intranet.contoso.com' -Name 'intranet' -Description 'intranet site' -OwnerAlias 'contoso\administrator' -HostHeaderWebApplication 'http://portal.contoso.com' -Template $siteTemplate

 

########### end Example #############

  • New-SPWebApplication -Name 'Contoso Sites' -port 80 -ApplicationPool ContosoAppPool -ApplicationPoolAccount (Get-SPManagedAccount 'Contoso\JDoe') -AuthenticationProvider (New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication) 

To create host-named site collections

New-SPSite 'http://portal.contoso.com' -HostHeaderWebApplication 'http://<servername>' -Name 'Portal' -Description 'Customer root' -OwnerAlias 'contoso\administrator' -language 1033 -Template 'STS#0'

Step 6. Managed Path for HNSC

New-SPManagedPath 'departments' –HostHeader
The following example shows a host-named site collection created at a managed path:
New-SPSite 'http://portal.contoso.com/departments/marketing' -HostHeaderWebApplication 'http://portal.contoso.com' -Name 'Marketing' -Description 'Portal Marketing' -OwnerAlias 'contoso\administrator' -language 1033 -Template 'STS#0'

**Find out Path based and Host Based **

**Determine host-named site collections in existing web applications **

$webApp = Get-SPWebapplication 'http://portal.contoso.com'
 
foreach($spSite in $webApp.Sites)
{
if ($spSite.HostHeaderIsSiteName) 
{ Write-Host $spSite.Url 'is host-named' }
else
{ Write-Host $spSite.Url 'is path based' }
}

 
#--------------------------

What is the difference between host name sitecollaiton and path based site collation

host-named site collections :

  • When you use host-named site collections, each site collection in a web application is assigned a unique DNS name
  • When you deploy many host-named site collections to a single web application, you increase scalability of the farm because resources are not used to support multiple application pools and web applications.
  • You can use Windows PowerShell to create host-named site collections. You cannot use Central Administration to create host-named site collections.
  • You can use zones to assign up to five URLs to host-named sites, including vanity URLs.
  • A root site collection is required to crawl content in a web application. A root site collection can be a site collection that users cannot access.
  • Use Windows PowerShell commands to manage URLs (Set-SPSiteURL, Remove-SPSiteURL, Get-SPSiteURL).
  •  Self Service Site Creation feature that is part of the default installation of SharePoint 2013 does not work with host-named site collections.

 

Path-based site collections :

 

Central Administration or Windows PowerShell to create path-based site collections.

 

All path-based site collections in a web application share the same host name (DNS name) as the web application.

You can extend a web application to implement up to five zones and create different host names for each zone.

Use Alternate Access Mappings to manage URLs.

Self Service Site Creation feature that is part of the default installation of SharePoint 2013,

Managed paths for path-based sites apply at the web application level.

Reff: https://gallery.technet.microsoft.com/office/host-named-collections-in-9f003c97