in

Dot Net Mafia

Group site for developer blogs dealing with (usually) .NET, SharePoint 2013, SharePoint 2010, Office 365, SharePoint Online, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for SharePoint 2013, Office 365 / SharePoint Online and Visual Studio 2013.

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

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

 

Robert said:

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

September 4, 2013 2:44 AM
 

Barry said:

Is there a way to do this in SP2010?

September 4, 2013 10:45 AM
 

Creating path-based site collections in conjunc... said:

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

September 4, 2013 12:49 PM
 

CoreyRoth said:

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

September 4, 2013 1:44 PM
 

CoreyRoth said:

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

September 4, 2013 1:45 PM
 

Robert said:

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

September 6, 2013 2:02 AM
 

Morgan Roach said:

I appreciate this helpful post!

http://www.desertedroad.com

September 17, 2013 1:19 PM
 

The Microsoft MVP Award Program Blog said:

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

September 20, 2013 4:30 PM
 

Friday Five – September 20, 2013 | MSDN Blogs said:

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

September 21, 2013 6:59 AM
 

Blog de Juan Carlos González en Geeks.MS said:

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

October 1, 2013 8:23 AM
 

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

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

October 1, 2013 8:24 AM
 

mike said:

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.

December 5, 2014 12:16 PM
 

CoreyRoth said:

@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.

December 5, 2014 1:00 PM

Leave a Comment

(required)  
(optional)
(required)  
Add

About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2012 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems