Link Provider generates cross-site links incorrectly


Description

In a multisite solution, the Link Provider might generate cross-site links incorrectly. For example, there are two custom site definitions:

<site name="site1" rootPath="/sitecore/content/site1" startItem="/Home" database="web" domain="extranet" enablePreview="true" hostName="site1" targetHostName="site1" />
<site name="site2" rootPath="/sitecore/content/site2" startItem="/Home" database="web" domain="extranet" enablePreview="false" hostName="site2" targetHostName="site2" />

The URL for a cross-site link incorrectly refers to:

http://site1/sitecore/content/site2/Home

It correctly ought to be resolved as:

http://site2/

The issue occurs if the enablePreview attribute of the site to be resolved is set to "false."

Solution

To resolve the issue, consider one of the following options: