Host Header Site Collections in SharePoint 2013
Host Header Site Collections allow to create site collections with unique host header urls. For example say our Webapplication is http://intranet.prod.com.
So in managed paths site collection we would have a site collection url say http://intranet.prod.com/sites/HR or http://intranet.prod.com/sites/Sales.
But we have requirement to make the site collection urls to look like http://sales.prod.com or http://hr.prod.com but still point to actual HR or Sales Site collection.
Please bear in mind here we are not creating two new web applications called hr and sales, instead we will be creating two site collections inside the web application http://intranet.prod.com.
So, let us see how we can achieve that -
First of all, host header site collections can only be created with Powershell. Another thing to keep in mind is that host header site collection cannot take advantage of Alternate Access Mapping (AAM).
So, to see the overview of the steps -
- Create the Web Application which will have host header site collections
- Create Site collections
- Add a DNS record
- Add binding to website in IIS
So, for this purpose say we already have a web application called http://intranet.prod.com, also the DNS entry for the site collection url has been added at http://hr.prod.com
Now for step 2, create a Site collection as follows -
We need to open powershell ISE and get the script executed as mentioned below -
Step 2:
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue;
New-SpSite "http://hr.prod.com"
-HostHeaderWebApplication "http://intranet.prod.com"
-Name "HR"
-OwnerAlias "prod\JDoe"
-Template "STS#;
Step 4:
New-WebBinding -Name "Intranet"
-ipaddress "*"
-port 80
-HostHeader "hr.prod.com";
Now, if we go to Central Admin --> Application Management --> View Site Collection
Select the Web Application in which the host header site collection was created which in our case is http://intranet.prod.com
We can now see the site collection called http://HR.Prod.com
That's it folks for this article, I would be posting more in the future.