1
votes

The Issue

We have two sites, one domain, we want to setup a virtual directory on the domain which can access the second site.

IIS virtual directory doesn't seem to do the trick, sitecore does not seem to play nicely.

Is there a potential work around using sitecore?

The Environment

We have the following folder structure for two of our sites:

  • C:\Sitecore\Site1

  • C:\Sitecore\Site2

Site 1 and Site 2 both connect to the same web, core and master databases.

To access the cms for both sites in the browser we do:

  • www.mysite1.com/sitecore

From Site 1's cms we create content, layouts and templates for Site 1 and Site 2.

The Solution

What we did is in the first sites web.config we defined the site as normal:

<site name="site1" hostName="mysite1.com" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/MyItem1/" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />

In the second sites web.config we defined the site slightly differently:

<site name="site2" hostName="mysite1.com" virtualFolder="/Site2" physicalFolder="/" rootPath="/sitecore/content" startItem="/MyItem2/" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />    

The second site we defined a virtual folder which you can notice above that was the only difference along with the obvious start item differences.

Site 1 will respond like normal. You can visit mysite1.com it will load the start item relevant for website 1.

When you visist mysite1.com/Site2/ it will load the virtual folder defined in the second site and load its relevant start item.

That is pretty much it works like a charm.

And finally @Mark Ursino thanks for your help.

To Note

You need have sitecore scalability configs enabled for any of the above to work

2
Please provide the <site ...> configuration from your web.config - Mark Ursino
Added the configs so you can see what I am essentially trying to do. - Anicho
Got it. Hmmm, I'm a bit confused about how myitem relates to /Partners/UK/ or /Partners/NZ/... is one of those what myitem is? - Mark Ursino
Yeah sorry there is only one site, with a start item of lets say: /MyItem/ ammended above. - Anicho
So when you access www.example.com/myitem-no2/ does it render that item? But when you call LinkManager.GetItemUrl(...) it renders as www.example.com/sitecore/content/myitem/myitem-no2/? I'm still not sure what the issue is fully. - Mark Ursino

2 Answers

4
votes

From what I think I understand, I think you need to make some changes in the config to set the "sub-folder site" as a virtualFolder:

<site virtualFolder="/subsite" physicalFolder="/subsite" rootPath="/sitecore/content" startItem="/MyItem/" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />

Note that virtualFolder="/subsite" and physicalFolder="/subsite" point to the subfolder, but I don't think you need that physical folder really there.

Reference used.