Reputation: 12619
I'm running a multi-site Sitecore 6.5 installation, upgrading to Sitecore 6.6. In 6.5, links to the top level domains behave normally, i.e. a link to the /sitecore/content/mydomain/home item resolves to mydomain.mysite.org, because it's set up to do so in web.config via the <sites>
entries.
After the upgrade to 6.6, that's not happening. The <sites>
entries are still in place, but the URL just points to mysite.org/sitecore/content/mydomain.home. Sitecore has been unable to pinpoint the issue because we have a number of customizations to the base setup (done by the initial vendor that set up the site). I'm assuming one of these customizations is to blame, but I'm having trouble pinpointing exactly where in the pipeline this is breaking down.
The actual code that's rendering the links is calling Sitecore.Links.LinkManager.GetItemUrl(), which is returning the bad URL immediately after the 6.6. upgrade package is installed. Any idea where the actual domain conversion is taking place, so I can start backing out some customizations to at least know where the problem is?
Update:
Here is the <sites>
section of the web.config (via showconfig.aspx). This is after applying suggestions from the answers to date, i.e. adding targetHostName and making the main site last in the order of site entries.
<sites>
<site name="shell" virtualFolder="/sitecore/shell" physicalFolder="/sitecore/shell" rootPath="/sitecore/content" startItem="/home" language="en" database="core" domain="sitecore" loginPage="/sitecore/login" content="master" contentStartItem="/Home" enableWorkflow="true" enableAnalytics="false" xmlControlPage="/sitecore/shell/default.aspx" browserTitle="Sitecore" htmlCacheSize="2MB" registryCacheSize="3MB" viewStateCacheSize="200KB" xslCacheSize="5MB" />
<site name="login" virtualFolder="/sitecore/login" physicalFolder="/sitecore/login" enableAnalytics="false" database="core" domain="sitecore" disableXmlControls="true" />
<site name="admin" virtualFolder="/sitecore/admin" physicalFolder="/sitecore/admin" enableAnalytics="false" enableWorkflow="true" domain="sitecore" loginPage="/sitecore/admin/login.aspx" />
<site name="service" virtualFolder="/sitecore/service" physicalFolder="/sitecore/service" />
<site name="modules_shell" virtualFolder="/sitecore modules/shell" physicalFolder="/sitecore modules/shell" rootPath="/sitecore/content" startItem="/home" language="en" database="core" domain="sitecore" content="master" enableAnalytics="false" enableWorkflow="true" />
<site name="modules_website" virtualFolder="/sitecore modules/web" physicalFolder="/sitecore modules/web" rootPath="/sitecore/content" startItem="/home" language="en" database="web" domain="extranet" allowDebug="true" cacheHtml="true" />
<site name="ga_website" virtualFolder="/" physicalFolder="/" hostName="medicare.martinspoint.local" targetHostName="medicare.martinspoint.local" rootPath="/sitecore/content/GA" startItem="/home" database="web" domain="HQ" allowDebug="true" cacheHtml="false" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" loginPage="http://martinspoint.local/account/login" />
<site name="groupplan_website" virtualFolder="/" physicalFolder="/" hostName="groupplan.martinspoint.local" targetHostName="groupplan.martinspoint.local" rootPath="/sitecore/content/GroupPlan" startItem="/home" database="web" domain="HQ" allowDebug="true" cacheHtml="false" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
<site name="hcc_website" virtualFolder="/" physicalFolder="/" hostName="healthcarecenters.martinspoint.local" targetHostName="healthcarecenters.martinspoint.local" rootPath="/sitecore/content/HCC" startItem="/home" database="web" domain="HQ" allowDebug="true" cacheHtml="false" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
<site name="usfhp_website" virtualFolder="/" physicalFolder="/" hostName="tricare.martinspoint.local" targetHostName="tricare.martinspoint.local" rootPath="/sitecore/content/usfhp" startItem="/home" database="web" domain="HQ" allowDebug="true" cacheHtml="false" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" loginPage="http://martinspoint.local/account/login" />
<site name="my_martinspoint_website" virtualFolder="/" physicalFolder="/" hostName="connect.martinspoint.local" targetHostName="connect.martinspoint.local" rootPath="/sitecore/content/mymartinspoint" startItem="/home" database="web" domain="HQ" allowDebug="true" cacheHtml="false" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
<site name="martinspoint_website" virtualFolder="/" physicalFolder="/" hostName="martinspoint.local" targetHostName="martinspoint.local" rootPath="/sitecore/content/martinspoint" startItem="/home" database="web" domain="HQ" allowDebug="true" cacheHtml="false" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
<site name="website" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" database="web" domain="HQ" allowDebug="true" cacheHtml="false" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
<site name="scheduler" enableAnalytics="false" domain="sitecore" />
<site name="system" enableAnalytics="false" domain="sitecore" />
<site name="publisher" domain="sitecore" enableAnalytics="false" enableWorkflow="true" />
</sites>
Upvotes: 0
Views: 926
Reputation: 17000
It sounds as through you are trying to link from one domain to another (or a subdomain at least). Make sure Rendering.SiteResolving=true
, which is the default value but it is worth checking:
<!-- SITE RESOLVING
While rendering item links, some items may belong to different site. Setting this to true
make LinkManager try to resolve target site in order to use the right host name.
Default value: true
-->
<setting name="Rendering.SiteResolving" value="true" />
As Ruud has suggested, sharing the <sites>
of your configuration may help and check the targetHostName
. It's not listed as a value in 6.6 config but you need to set this if you have multiple hostNames set.
Also verify the ordering of your <site>
config elements this that determines which site context is matched. More specific domains should be ordered first, so mydomain.mysite.org
should be listed before mysite.org
.
Check your final configuration from http://<url>/sitecore/admin/showconfig.aspx
(or use Sitecore Rocks) since it may be patched in using a Sitecore Include file.
EDIT: I've remembered what the issue is :)
Unfortunately the default UrlOptions and LinkManager ignore the Rendering.SiteResolving
(or maybe it was a bug in this particular version of Sitecore), since the default LinkProvider does not initialize this setting!
You need to create your own LinkProvider, inheriting from the Sitecore one and overwrite the GetItemUrl()
method passing through this setting:
namespace Sitecore.Sample
{
public class CustomLinkProvider : LinkProvider
{
public override string GetItemUrl(Item item, UrlOptions options)
{
// use the SiteResolving option set in config
if (Sitecore.Context.PageMode.IsNormal)
options.SiteResolving = Sitecore.Configuration.Settings.Rendering.SiteResolving;
return base.GetItemUrl(item, options);
}
}
}
And in your config switch out with your provider:
<linkManager defaultProvider="customProvider">
<providers>
<clear />
<add name="sitecore" ... />
<add name="customProvider" type="Sitecore.Sample.CustomLinkProvider, Sitecore.Sample"
addAspxExtension="true" alwaysIncludeServerUrl="false" encodeNames="true"
languageEmbedding="asNeeded" languageLocation="filePath"
lowercaseUrls="false" shortenUrls="true" useDisplayName="false" />
</providers>
</linkManager>
You can read more about it in this blog post.
Upvotes: 0
Reputation: 8877
The result of Sitecore.Links.LinkManager.GetItemUrl
is determined by the LinkProvider
which is configured in your config, here:
<linkManager defaultProvider="sitecore">
<providers>
<clear />
<add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel"
addAspxExtension="true" alwaysIncludeServerUrl="false" encodeNames="true"
languageEmbedding="asNeeded" languageLocation="filePath"
lowercaseUrls="false" shortenUrls="true" useDisplayName="false" />
</providers>
</linkManager>
You vendor has probably overridden that setting with a custom provider.
Upvotes: 0