What is Host-Named Site Collection?
Host-named site collections enable you to assign a unique DNS name to site collections. For example, you can address them as http://TeamA.contoso.com and http://TeamB.contoso.com. This enables you to deploy many sites with unique DNS names in the same web application. It also enables hosters to scale an environment to many customers. If you do not use host-named site collections, your SharePoint web application will contain many path-based site collections that share the same host name (DNS name). For example, Team A has a site collection at http://contoso.com/sites/teamA, and Team B has a site collection at http://contoso.com/sites/teamB.
You can read more about the Host-named site collection architecture and deployment in SharePoint 2013 here. This article has listed a very good comparison of host-name site collections to the path based site collections. However, one of the key advantage which host-named site collection offers is the transparent experience to the end users which was difficult to achieve in earlier versions of SharePoint. Till SharePoint 2010, the only way to have a dedicated URL mapping was on a Web Application level through alternate access mapping.
It should be noted that there is no user interface to create a host-named site collection from SharePoint 2013 Central administration and is possible only via PowerShell command, which is not very complex either. Below example shows how to create a host-name site collection which can be accessed via the DNS entry http://manasbhardwaj.net
Add-PSSnapin Microsoft.SharePoint.PowerShell
$currentUser = "$env:USERDOMAIN\$env:USERNAME"
$siteCollectionUrl = "http://manasbhardwaj.net"
$siteCollectionName = "Manas Dev Site"
$webApplicationUrl = "http://manas"
New-SPSite -Url $siteCollectionUrl -OwnerAlias $currentUser -Name $siteCollectionName -Language 1033 -HostHeaderWebApplication $webApplicationUrl -Template sts#0
Create Default Groups in a Host-Named Site Collection
However, when you use the above script to create a host-named site collection it does not create the default groups (such as Owners, Members and Visitors) which are available if the site collection is created using the Central Administration user interface.
Look at the image above and you can see the groups are missing. But the good news is that it is still possible to create the default groups using a couple of lines of script.
Add-PSSnapin Microsoft.SharePoint.PowerShell
$currentUser = "$env:USERDOMAIN\$env:USERNAME"
$siteCollectionUrl = "http://manasbhardwaj.net"
$siteCollectionName = "Manas Dev Site"
$webApplicationUrl = "http://manas"
New-SPSite -Url $siteCollectionUrl -OwnerAlias $currentUser -Name $siteCollectionName -Language 1033 -HostHeaderWebApplication $webApplicationUrl -Template sts#0
$web = Get-SPWeb $siteCollectionUrl
$web.EnsureUser($currentUser)
$web.CreateDefaultAssociatedGroups($currentUser, "", "")
What you need to do is call the CreateDefaultAssociatedGroups once your site collection has been created. And this will ensure that the default groups are created for the specified site collection.
Update hosts file (on local Development Environment)
If you want to create a host-named site collection on your development environment, you might need to update your local host file to create an entry for the specified Url. In a real test or production environment, you would have a actual DNS VIP entry which you can use to redirect to your site collection. So, for e.g.
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 manasbhardwaj.net
Be First to Comment