Non-Root Site Collections
Microsoft SharePoint 2010 supports the concept of a non-root site collection, which is a site collection that is not hosted at the root of a Web application. This allows for the deployment of multiple sites within a Web application, sharing of service providers (SSPs) and management of the sites with a single set of security rights. From an overhead perspective, this also minimizes the total number of the required Microsoft Internet Information Services (IIS) Web applications.
For information about creating a non-root site collection in SharePoint 2010 without using the SharePoint Commerce Services Configuration Wizard, such as in a three-tier commerce deployment, see Creating a Non-Root Site Collection Using PowerShell Commands.
About the Home Token
To implement non-root site collections, SharePoint Commerce Services introduces a home token denoted by ~home to be set to the URL to which the Solution Storefront is deployed.
Home Token Usage
The following are usage examples of the ~home token.
Root Site Collection
URL: http://pcname/
Home Token: /
Non-Root Site Collection
URL: http://pcname/sites/Commerce
Home Token: /sites/Commerce
Sub Site
URL: http://pcname/Commerce
Home Token: /Commerce
Root Site Collection Site Variation
URL: http://pcname/English
Home Token: /English
Non-Root Site Collection Site Variation
URL: http://pcname/sites/Commerce/English
Home Token: /sites/Commerce/English
By using the ~home token, you can define URLs in master pages or site pages such as the following HTML image reference:
<img src="<% $CSUrl:~home/PublishingImages/Skin/Skin_Logo.jpg %>" alt="logo" runat="server" />
The ~home token is parsed by the CSUrl expression builder that is responsible for replacing the ~home token with the URL that has been set for that particular site.
If you are using the SharePoint Commerce Services Configuration Wizard, this functionality is implemented in the provisioning feature that is activated when the Solution Storefront provisions. At that time, the URL will be known and stored in the property bag of the current site.
Note
The ~home token should not be used when referencing templates in Microsoft SharePoint 2010 document libraries. For example, the SPProductQuery Web Part has a property called XslTemplateUri, which is set to [Templates]/ProductQuery/DefaultSite_ProductQuery.template. In this case, Microsoft SharePoint 2010 will successfully reference the template in the current site. If you precede the template URL with the ~home token, Microsoft SharePoint 2010 will fail to locate the template.
Setting the Home Token for the Solution Storefront
The ~home token is set automatically when you install the Solution Storefront.
Setting the Home Token on an Existing Solution Storefront Site or on a Custom Web Application That Uses the Commerce Web Parts
The value of the ~home token may need to be configured after the Solution Storefront site has been provisioned or when only deploying the Web Parts and not the Solution Storefront.
To configure the ~home token and Login page
Navigate to the Solution Storefront site or your site.
Click Site Actions, click Site Settings, and then click Modify All Site Settings.
On the Site Settings page, under the Site Administration section, select Commerce Server Site Settings.
On the Commerce Server Site Settings page, set the Home Web URL to your site's home page URL and set the Login Page to your site's login page.
Click OK.
Creating a Non-Root Site Collection Using PowerShell Commands
If you did not use SharePoint Commerce Services Configuration Wizard to deploy the Solution Storefront, such as in a three-tier commerce deployment for example, you can use Windows PowerShell commands to create a non-root site collection in SharePoint 2010. Following is an example of a PowerShell script that creates a non-root site collection in SharePoint 2010. Update the script variables based on your environment.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"
$WebSiteUrl = "http://<SiteURL>:8088/Sites/<site2>"
$SiteOwner = "<Domain>\<UserName>"
$webTemplates = Get-SPWebTemplate
if($webTemplates)
{
foreach ($webTemplate in $webTemplates)
{
# Write-Host "--> " $webTemplate.Name
if($webTemplate.Name -like "*CSStorefrontSite#0")
{
Write-Host "Creating Root Site Collection " $webTemplate.Name
New-SPSite -Url $WebSiteUrl -OwnerAlias $SiteOwner -Name "Store" -Template $webTemplate
Write-Host "Root Site Collection created ..."
}
}
}
$site = Get-SPSite $WebSiteUrl
if($site)
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$site.AllWebs[0].AnonymousState = [Microsoft.SharePoint.SPWeb+WebAnonymousState]::"On";
$site.AllWebs[0].Update();
}
See Also
Other Resources
How to Create a Host Named Site Collection Exposed Only on the Default Zone