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 : |
||||
|
Reff: https://gallery.technet.microsoft.com/office/host-named-collections-in-9f003c97