Sharepoint 2013 Host Named Site Collections

Setting up Sharepoint 2013 with host named site collections is a great way to have individual URLs for each site and have a few, or even a single web application. This is one of things I have working on during the 9 – 5 grind. Sharepoint 2013 can only handle so many web applications, and if you add too many then Sharepoint will bog down and you will start to see it takes longer and longer to create the web applications that you need. Add more then 20 web applications to a Sharepoint installation and soon you will see timeouts and random errors occuring with Sharepoint as it struggles to keep up. The solution is setting up a Host Named Site Collection. Follow my instructions below and you will be up and flying in no time. I have also included instructions for setting up SSL Host Named Site Collections as well.

Host Named Site Collections cannot be setup from the Web based GUI. Instead you will need to use the Sharepoint Management Shell using Windows Powershell.

Creating a Host Named Site Collection

1. Start the Sharepoint Management Shell as administrator. From here you will want to create the Web Application that will run the host named site collection. Use the New-SPWebApplication cmdlet.

       New-SPWebApplication -Name “Contoso Sharepoint Sites” -HostHeaderWebApplication “http://webapp.contoso.com”
       -Port 80 -ApplicationPool “ContosoAppPool” -ApplicationPoolAccount (Get-SPAutheticationProvider
       -UseWindowsIntegratedAuthetication)

Should you want to add an SSL certificate to the web application you would replace http://webapp.contoso.com with https://webapp.contoso.com. Change the port to 443 and add the -SecureSocketsLayer switch to the end of the Powershell command.

2. Next you will need to setup the IIS web bindings for the application. With PowerShell running as administrator use the New-WebBinding cmdlet.

       New-WebBinding -Name “Contoso Sharepoint Sites” -HostHeader “*” -Ipaddress “*” -Port 80 -Protocol http

If you are using SSL Certificates you will want to change the port to 443 and the protocol to HTTPS. Once that is complete launch IIS and find the IIS site and edit the bindings for the site. Assuming you have a wild card SSL Certificate installed for your domain (Should look like *.contoso.com) simply select the certificate from the the list to apply that certificate to the web application. Should you not have any certificates installed, do a quick Google search on how to install your SSL Certificates.

3. Now you will need to create a Root Site Collection. This site collection is mandatory, and in most cases is not used for storing any sites that you want people to be viewing. I suggest using the values for the cmdlet as seen below exactly. Keep in mind for the -OwnerAlias field use the farm administrator account that you setup when installing Sharepoint 2013. Also replace instances of Contoso with the domain that you are using.

       New-SPSite “root.contoso.com” -HostHeaderWebApplication “webapp.contoso.com” -Name “Root Site” -Description
       “Root Site Collection” -OwnerAlias “contoso\sp2013_admin” -language 1033 -template “STS#0”

4. After you have created the root site collection you are now free to create the individual sites required using the New-SPSite cmdlet. Repeat as necessary to create all your sites.

       New-SPSite “http://ExampleSite.contoso.com” -HostHeaderWebApplication “webapp.contoso.com” -Name “Contoso
       Example Site”
-Description “Contoso Example Site” -OwnerAlias “contoso\sp2013_admin” -Language 1033 -Template
       “STS#0”

5. Next you will want to go into your domain's DNS on your domain controller and create an new Host Record for each site you create. Create a host record with example.contoso.com and point it to the IP Address that the Sharepoint Sites are binded to in IIS. All that is left is to open a web browser and find the site by its host name.

Congratulations you have created a Host Named Site Collection.

Migrate Sharepoint Web Applications

Now if you had a Sharepoint 2013 Installation that was using a different Web Application for each site then you will want to move the current data over to the new Host Named Site Collection. This is done through a backup of the old Sharepoint site and then a restore to the new host named site collection.

1. First create a backup from old Sharepoint Server. You will just want to backup the single site so use the Backup-SPSite cmdlet.

       Backup-SPSite -Identity “http://ExampleSite.contoso.com” -Path “c:\Sharepoint_Site_Backups\examplesite.bak” -Force
       -UseSQLSnapShot

This command will create a backup of the site and store it where you specified the -Path to be. Now copy and paste the backup to the new Sharepoint Server and run the next cmdlet.

2. The below cmdlet will restore a backed-up Sharepoint site on the new server.

       Restore-SPSite -Identity “http://ExampleSite.contoso.com” -Path c:\Sharepoint_Site_Backups\examplesite.bak” -Force
      -HostHeaderWebApplication “http://webapp.contoso.com” -Confirm:$false

Lastly browse to the address to which you restored the site to confirm everything went off without a hitch.

Enjoi!

                                                        T3rr0rByte13@hobbyware.org

                                                                                                     ©2020 All Rights Reserved. All contents of this site are copyright to Hobbyware.org