A host-named site collection allows you to address a site collection with a unique DNS name.
SharePoint decides the mapping of the host nName with the Site Collection at the time of initializing SPSite Object. During the initialization process, SharePoint queries SPWebApplication object to see if host header details are associated with the Site Collection and if there is no information returned on host headers, then it becomes evident that this is a typical Site Collection.
If we inspect the ULS logs for Site Collections with host headers, we will see the entries like Site lookup, which has found the host header site. On the other hand, if we inspect the same logs for Site Collections without host headers looking up the additional information about the typical site http://serverName:Port/sites/site001
In this article, we will look into the steps to create host header based Site Collections, as per the process given below.
Step 1
Add DNS entry
- Search for DNS on Windows Server.
- Select the domain name.
- Right click and select New Host.
- Enter new host name.
- Enter IP address of the Hosting Server.
- Click Add Host.
This will add a new host name entry in the DNS Catalog.
Step 2
Create Site Collection
Since we don’t have Web UI available to create the host header based Site Collections, so the only option with which we are left with is PowerShell only.
PowerShell command, which we can use to create a host header based Site Collection is given below.
In this command, we have the parameters and their values given below.
Once you execute PowerShell, we can see the output given below.
We can verify the creation of the new host header Site Collection by going to Central Administrator -> Application Management -> View All Site Collections
Step 3
Add Site Binding
PowerShell command is given below, which we can use to Add the Site Binding in IIS.
- New-WebBinding -Name “Development – Portal” -IPAddress “*” -Port 2016 -HostHeader “developerWorkspace001.PRASHANT.LOCAL”
In this command, we have the parameters and their values given below.
Once PowerShell executes successfully, we can see the output given below on the command prompt.
We can verify the creation of Site Binding in the IIS by using the steps givenn below.
- Search for IIS on Windows Server.
- Select the Web Application and click Bindings Links, as shown below.
- On the Site Bindings Window, we can see a new Site Binding is added to IIS.
- Select Site Binding and click Edit button to open Edit Site Binding Window.
This shows that binding is created successfully.
Now, lets visit the host header Site Collection by visiting the URL given below.
http://developerWorkspace001.PRASHANT.LOCAL
Enter the credentials when it asks.
The screenshot given below pops up.
Hope, you found it helpful.