Creating path-based site collections in conjunction with your host-named site collections

Posted Tuesday, September 3, 2013 3:17 PM by CoreyRoth

In SharePoint 2013, host-named site collections (HNSC) are all the rage.  SharePoint Online has been using them heavily for some time now and in general, they are the preferred method for creating site collections now with SharePoint 2013.  If you aren’t familiar with what I mean by host-named site collections, let me give you an example.  Host-named site collections give you the ability to provide completely different URLs for a site collection regardless of the web application URL hosting it.  For example, you might have a web application URL named http://sharepoint.mycompany.com and under it you have a collaboration site with a URL of http://collaborate.mycompany.com and an Intranet site named http://intranet.mycompany.com.  This allows you to host multiple types of SharePoint sites together on a single web application which ultimately reduces the amount of resources your server farm needs for application pools.

Host-named site collections are great, but what if we want to append a path-based site collection onto our HNSC?  The TechNet article does a good job explaining HNSC but when I read it, it wasn’t clear to me if you could combine the two. Now, this is interesting but what if your HR department wants their own site collection under http://collaborate.mycompany.com?  You could always give them an HNSC as well such as http://hr.mycompany.com.  However, if you don’t want that and you really want the URL to be located under your other URL such as http://collaborate.mycompany.com/hr, this can be done with some simple PowerShell commands.  If you have worked with HNSC before, you know PowerShell is our only option if we want to use them as there is not any place in Central Administration to set them up.

Just like any site collection, you have to create a managed path for the URL you want.  We do this using New-SPManagedPath.  We can add explicit or wildcard inclusions just like you can for path-based site collections.  Wildcard is the default, if you want explicit, include the –explicit parameter.  We also need to add the –HostHeader parameter to indicate this is used with host-named site collections.  Here’s an example, where I created the HR explicit path from our example above.

New-SPManagedPath "MyPath" -HostHeader -Explicit

HNSCPowerShellAddManagedPath

This technically makes this managed path available on any host-named site collection.  If you want to see what managed paths have been created for host-named site collections, use Get-SPManagedPath with the –HostHeader command.

Get-SPManagedPath -HostHeader

HNSCPowerShellGetManagedPath

Now, we need to create the site collection using New-SPSite.  It takes a few parameters but the important ones for this scenario is the URL we want for the new site collection and then –HostHeaderWebApplication to specify which web application hosts the new site collection.

New-SPSite http://wingtip.com/mypath -HostHeaderWebApplication http://webapplicationurl -Name "Site Name" -OwnerAlias domain\user -Template STS#0

HNSCPowerShellNewSiteCollection

When the command is done, you will have a new site collection at the URL you specified.  Give it a try for yourself.

Comments

# re: Creating path-based site collections in conjunction with your host-named site collections

Wednesday, September 4, 2013 2:44 AM by Robert

Hi and thanks for this useful post. Is it possible to create the Site Collection directly on the Managed Path?

# re: Creating path-based site collections in conjunction with your host-named site collections

Wednesday, September 4, 2013 10:45 AM by Barry

Is there a way to do this in SP2010?

# Creating path-based site collections in conjunc...

Wednesday, September 4, 2013 12:49 PM by Creating path-based site collections in conjunc...

Pingback from  Creating path-based site collections in conjunc...

# re: Creating path-based site collections in conjunction with your host-named site collections

Wednesday, September 4, 2013 1:44 PM by CoreyRoth

@Robert not sure what you are meaning exaclty.  Can you provide more details?  Thanks!

# re: Creating path-based site collections in conjunction with your host-named site collections

Wednesday, September 4, 2013 1:45 PM by CoreyRoth

@Barry I'll need to look into that...

# re: Creating path-based site collections in conjunction with your host-named site collections

Friday, September 6, 2013 2:02 AM by Robert

Hi again, I meant you created the managed path "MyPath" like this New-SPManagedPath "MyPath" -HostHeader -Explicit

and then directly you created a new Site Collection on same path "MyPath" like this.

New-SPSite http://wingtip.com/mypath -HostHeaderWebApplication http://webapplicationurl -Name "Site Name" -OwnerAlias domain\user -Template STS#0

# re: Creating path-based site collections in conjunction with your host-named site collections

Tuesday, September 17, 2013 1:19 PM by Morgan Roach

I appreciate this helpful post!

http://www.desertedroad.com

# Friday Five - September 20, 2013

Friday, September 20, 2013 4:30 PM by The Microsoft MVP Award Program Blog

1. Using Microsoft Dynamics CRM 2011 and Internet Explorer 10 By Dynamics CRM MVP Chris Cognetta –

# Friday Five – September 20, 2013 | MSDN Blogs

Saturday, September 21, 2013 6:59 AM by Friday Five – September 20, 2013 | MSDN Blogs

Pingback from  Friday Five  – September 20, 2013 | MSDN Blogs

# SharePoint 2013: Recopilatorio de enlaces interesantes (XV)!

Tuesday, October 1, 2013 8:23 AM by Blog de Juan Carlos González en Geeks.MS

Como cada mes, aquí os dejo el recopilatorio de enlaces interesantes sobre SharePoint 2013 y Office 365

# SharePoint 2013: Recopilatorio de enlaces interesantes (XV)! | Pasi??n por la tecnolog??a...

Pingback from  SharePoint 2013: Recopilatorio de enlaces interesantes (XV)! | Pasi??n por la tecnolog??a...

# re: Creating path-based site collections in conjunction with your host-named site collections

Friday, December 5, 2014 12:16 PM by mike

You say "SharePoint Online has been using [HNSC] heavily for some time now"

Everything I've read from the MS documentation says exactly the opposite. According to that, HNSC are only possible for on-premise installations of SharePoint 2013 and are NOT an option for SharePoint Online (nor have they ever been). If that isn't the case I would love to find out how to do is as I would prefer using HNSC over paths.

# re: Creating path-based site collections in conjunction with your host-named site collections

Friday, December 5, 2014 1:00 PM by CoreyRoth

@Mike to clarify that, SPO uses HNSC behind the scenes for the multi-tenant configuration.  Your public site is an example of a site that uses HNSC.  Unfortunately though as you mentioned, you can't create your own HNSC and you are locked into your tenant name for the prefix.

# re: Creating path-based site collections in conjunction with your host-named site collections

Thursday, October 8, 2015 5:15 PM by Dennis

It looks like you assign a host to your host web.  Doesn't this mean that you have to add the host from each HNSC to the web app as well?

I'm just wondering the pros/cons of having no host assigned to the web app.  Basically just using the server name.

# re: Creating path-based site collections in conjunction with your host-named site collections

Friday, October 9, 2015 8:58 AM by CoreyRoth

@Dennis SharePoint will usually take care of adding the host header to the web application.  Sometime it doesn't though so if you are experiencing issues.  You want to check that.  HNSC just gives you more flexibility in what you name things.

# re: Creating path-based site collections in conjunction with your host-named site collections

Friday, October 9, 2015 9:01 AM by CoreyRoth

@Mike I think the parameter for your -HostHeaderWebApplication is supposed to be spserver.company.com if I remember right.

# re: Creating path-based site collections in conjunction with your host-named site collections

Friday, October 28, 2016 8:09 AM by Rishi Pandit

But you must know, Sharepoint (2007, 2010, 2013 & even 2016) is limited only to 20 managed path per site collection. You will get stuck after provisioning 20 managed path site collection. If your requirement is not so vast, you can surely go with this great post. Thanks CoreyRoth for this post.

Leave a Comment

(required)
(required)
(optional)
(required)