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
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
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 #############
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'
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
$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 :
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.