次の方法で共有


Host named site collections in SharePoint 2013

What are HNSC

Traditional site collections that we create in SharePoint are Path based site collections

image

Host named site collections have their own url. 

Example

Microsoft recommends using host named site collection.  It is used in SharePoint online and Office 365.

Benefits of HNSCs

A SharePoint farm can have 20 web applications at max.  If we use path based site collections in order to have unique urls we need to create different web applications with different host names.

For example if we need to create following site collections

1. www.companyA.contoso.com/

2. www.companyB.contoso.com

3. www.portals.com

By using path based site collections we need to create 3 web application with appropriate host names. 

But by using host named site collections we can create one web application and 3 site collections with different urls.

Path based site collection are not scalable as we can create at max 20 web applications, while a sharePoint farm can have at max 250000 site collections using shared content database.

When to use Path Based site collections

1. You want separate application pools.

2. You have requirement of self service site creation feature. - You need to use a custom solution for self-service site creation with host-named site collections.

How to create HNSC

HNSC can be created only through powershell script

  1. Create web application
  2. Create root site collection (required for crawling)
  3. Create host named site collections
  4. Set alternate URLs for host named site collection

Let us have a closer look.

  • Create a web application (either through central admin or through powershell). 

I created through central admin

port – 100

Web app name – SharePoint – 100

  • Now create a root site collection.   When root site collection is crawled, all HNSC s also get crawled although they do not appear in content sources

New-SPSite 'https://<servername>:100' -Name 'Root Portal' -Description 'Root site collection' -OwnerAlias 'contoso\administrator' -language 1033 -Template 'STS#0'

  • Now create HNSC.  Use following powershell to create HNSC

New-SPSite 'https://CompanyA.contoso.com:100' -HostHeaderWebApplication 'https://<servername>:100’ -Name ‘CompanyA portal’ -Description 'Portal for CompanyA' -OwnerAlias 'contoso\administrator' -language 1033 -Template 'BLANKINTERNET#0'

New-SPSite 'https://CompanyB.contoso.com:100' -HostHeaderWebApplication 'https://<servername>:100’ -Name ‘CompanyB portal’ -Description 'Portal for CompanyB' -OwnerAlias 'contoso\administrator' -language 1033 -Template 'BLANKINTERNET#0'

Managed paths with host-named site collections

Managed paths can be used with host-named site collections.  Managed paths for HNSC are different from path based site collections.  Managed paths for HNSC are available to all HNSCs in the farm regardless of the web application.  They are limited to 20 per farm.  While managed paths for path based site collection do not apply to path based site collectioins in other web applications. 

To create managed path for HNSC we need to use powershell

New-SPManagedPath ‘dept’ –HostHeader

Now we can create HNSC with managed path

New-SPSite ‘https://CompanyA.contoso.com:100/dept/Technology’ –HostHeaderWbApplication ‘https://<servername>:100’ –Name ‘Technology’ –Description ‘Technology department’ –OwnerAlias ‘contoso\administrator’ –language 1033 –Template ‘BLANKINTERNET#0’

Managed path for path based site collection can be defined at central admin or using powershell

New-SPManagedPath [-RelativeURL] "</RelativeURL>" -WebApplication <WebApplication> creates managed path for a particular web application that can be used by path based site collections of that particular web application

Having done this you can check by browsing the site

Note : – In case you see a 404 error and if you are browsing the site on same local SharePoint server, you would need to change the host file to include then entry

for example to browse https://companyA.contoso.com:100 the entry in host file would be

127.0.0.1 companyA.contoso.com

Further you need to disable LoopBack in registry. To do this manually open registry using regedit and nav to HKEY_LM\System\CCS\Control\LSA

Create dword key with name ‘DisableLoopbackCheck’. Change the value to 1 for this.

It can also be done using powershell

New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck" -Value "1" -PropertyType dword

Comments

  • Anonymous
    May 21, 2014
    The comment has been removed
  • Anonymous
    May 21, 2014
    The comment has been removed
  • Anonymous
    May 22, 2014
    Thanks. So before I celebrate let me be clear about what I'm doing and ask a couple of questions:
  1. installed sharepoint foundation 2013. Your insructions say to create a root site collection before creating the host named sites. However, I read that the sharepoint foundation 2013 install creates the default web application and site collection.I see that a sharepoint-80 web app was created by the install but when I try to list the site collections nothing is listed. What confuses me is that I can access what looks to be a default web site named "Home" by putting http://<servername> in my browser. I thought that would only happen if I had a site collection? So, do I already have a root site collection created by the install? 2.When you mean proper quotes you mean " instead of the '? Thanks  
  • Anonymous
    May 22, 2014
    So, I executed the command with the " and it seems to have worked. However, I mistyped one of the urls I created. How do I fix that? Thanks

  • Anonymous
    May 22, 2014
    I was able to delete and recreate the mistyped site collection. I can see my new site collections in central admin. However, when I put the urls in the server browser, I don't see any of the sites exept for the root site. Any help would be appreciated. Thanks

  • Anonymous
    May 22, 2014
    What error do you get?  Also don't forget to add host entry in the host file.  Also if you are browsing site from the same sharepoint server (which I guess you are) add a loopback entry.  Have mentioned in the end of blog.  If you cannot see any error, install and check on fiddler to check actual error.  

  • Anonymous
    May 23, 2014
    I put the urls in my hosts file and disabled loopback. On the server I get, " you may be trying to access this site from a secured browser. Enable scripts and reload this page". From one of my client laptops I get "Sorry, We could not find "URL" . It may be unavailable or may not exist..."

  • Anonymous
    May 23, 2014
    Update: I can see the sites on the server after adding them to trusted sites. However, can't see them anywhere else including computers on the same network.

  • Anonymous
    May 25, 2014
    To see them on other computers on the same network you need to add host entry in the host file of that computer Instead of 127.0.0.1, you should put the ip address of the web front end server.

  • Anonymous
    May 26, 2014
    Thanks. I think my next question may be a dumb one, but how do I make my sites accessible remotely or maybe the correct term is publicly on computers outside the network? Let me give you a little background. I am using windows home server 2011. I know it is no longer supported, but I still use it because  it still does everything I need without having to learn all the ends and outs of server administration (at least until now). The server came with a default web site and domain name (x.homeserver.com/remote) that gives me remote access to the server. This site resides on port 80 and 443. To get share point to work, I removed the IIS bindings to port 80 for the home server default site. Now, I can reach my share point default site remotely on port 80 by going to http://x.home server.com and I can reach the home server default site by going to https://x.homesever.com/remote on port 443. I started down the road of host named site collections because I want to make them accessible remotely or publicly without using the x.home server.com domain name. However, I am starting to think that I am missing an important piece to making this work.. Sorry for the long reply and thanks for your help.

  • Anonymous
    October 08, 2014
    Great article.  Couldn't be more clear.  Thanks for posting it.

  • Anonymous
    November 25, 2014
    Just a bit of an FYI regarding creating host-named site collections using SharePoint Online. I have been finding lots of conflicting information about this so finally called MS Support. Just got off the phone with them in fact. Their official word is: Creating host-named site collections is NOT an option using SharePoint Online (aka SharePoint 2013 Online, aka SharePoint 365). So the statement early in this post about it being "used in SharePoint online and Office 365" is only half right ;)

  • Anonymous
    July 20, 2015
    First site collection has been created successfully: New-SPSite ‘companya.contoso.com/.../Technology’ ... Second one failed: New-SPSite ‘companyb.contoso.com/.../Technology’ ... Question: Can we use the same SP2013 managed path to create multiple site collections (as above)? Thanks.

  • Anonymous
    October 24, 2015
    I tried the same Powershell script the Site collection is created but getting an error page can't be displayed while trying to run the site collection.Can you help me with this.?

    • Anonymous
      October 28, 2016
      The comment has been removed