We have a project with 2 sites set up via Bindings in IIS.
All works well apart from when a content editor adds an internal link. Sitecore stores a value in the field such as
/OSS/Home/Assets/Freshwater wildlife
But the link doesn't resolve (404) until we remove the site name and Home to get a path
/Assets/Freshwater wildlife
I think the full path, /OSS/Home/Assets/Freshwater wildlife, is correct but how do we get Sitecore (6.5) to recognize this URL?
first of all, you need to ensure your solution use correct hostnames when you rendering that links.
Please check your site configuration :
<site name="website_1" hostName="www.site1.com" language="en" cacheHtml="false" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/site1" startItem="/home" database="web" domain="extranet" allowDebug="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
<site name="website_2" hostName="www.site2.com" language="en" cacheHtml="false" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/site2" startItem="/home" database="web" domain="extranet" allowDebug="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
if it's something like this.
Also please check if Rendering.SiteResolving is true on web.config.
<setting name="Rendering.SiteResolving" value="true" />
How you render your links on code ?
If you render with :
Sitecore.Links.UrlOptions defaultOptions = Sitecore.Links.UrlOptions.DefaultOptions;
string itemUrl = Sitecore.Links.LinkManager.GetItemUrl(item, defaultOptions);
please add:
defaultOptions.SiteResolving = true;
Related
I want to change the default home page of Sitecore to MyPage. And I have tried the below code by placing it in web.config file
<site
name="GrandThornton"
virtualFolder="/"
physicalFolder="/"
rootPath="/sitecore/content"
startItem="/GTHomePage"
language="en"
database="web"
domain="extranet"
allowDebug="true"
cacheHtml="true"
htmlCacheSize="10MB"
enablePreview="true"
enableDebugger="true" />
And when I try placing the code it is throwing an error showing
The error message is telling you that the configuration reader did not expect the <site ... /> element to be located where it was found. Remove that node from your Web.config and the error will go away.
Sitecore site definitions are by default located in App_Config\Sitecore.config under <sitecore> -> <sites>.
You could add your site definition to the Sitecore.config, but there is an even better approach: Sitecore patch files. Here's how you can apply it:
Create a new file in App_Config\Include and name it SiteDefinition.config. Add the following content in this file:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<sites>
<site patch:before="site[#name='website']"
hostName="GrandThornton"
name="GrandThornton"
virtualFolder="/"
physicalFolder="/"
rootPath="/sitecore/content"
startItem="/GTHomePage"
language="en"
database="web"
domain="extranet"
allowDebug="true"
cacheHtml="true"
htmlCacheSize="10MB"
enablePreview="true"
enableDebugger="true" />
</sites>
</sitecore>
</configuration>
Remember to change the hostName attribute to the domain name you want to use with this site.
The new site should work after this.
I've created "Simple HTML message" and added some internal links in the Message body using rich text editor
In html it look like this:
TEST
When I sending test message this link is converted to: http:mydomain.com/://mydomain.com/TEST
This link is broken, redundant part - ://mydomain.com/
How I can fix it?
LinkManager.config
<add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="false" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="never" languageLocation="filePath" lowercaseUrls="false" shortenUrls="true" useDisplayName="true" siteResolving="true" patch:source="LinkManager.config"/>
Sites.config:
<site name="Website3" targetHostName="site1.mydomain.com" hostName="site1.mydomain.com" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/site1.mydomain.com" startItem="/home" language="en" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" patch:source="Sites.config"/>
<site name="Website2" targetHostName="site2.mydomain.com" hostName="site2.mydomain.com" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/site2.mydomain.com" startItem="/home" language="en" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" patch:source="Sites.config"/>
<site name="Website1" targetHostName="mydomain.com" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/www.mydomain.com" startItem="/home" language="en" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" patch:source="Sites.config"/>
how to specify a login page? I`m getting such error while trying to access some page:
Error: Login is required, but no valid login page has been specified for the site (sitename).
My webconfig contains such records:
<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" analyticsDefinitions="content" xmlControlPage="/sitecore/shell/default.aspx" browserTitle="Sitecore" htmlCacheSize="2MB" registryCacheSize="3MB" viewStateCacheSize="200KB" xslCacheSize="5MB" disableBrowserCaching="true" />
<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="website" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" 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" loginPage="/shop/account/login"/>
<site name="scheduler" enableAnalytics="false" domain="sitecore" />
<site name="system" enableAnalytics="false" domain="sitecore" />
<site name="publisher" domain="sitecore" enableAnalytics="false" enableWorkflow="true" />
</sites>
I have tried to set path to the login page in website as a loginPage attribute, but it doesn`t work
This error only happens in the following three cases:
The site's loginPage attribute is missing or empty.
You're currently in the "edit" or "preview" mode AND the shell site is undefined or its loginPage is undefined or empty.
Sitecore.Context.Site is null.
To troubleshoot this, you can try the following:
Determine which <site> the page you're accessing belongs to. Are you 100% sure it's the <site name="website">?
Verify that the loginPage attribute is not empty for that site.
Open the page where you're getting the error in the "normal" mode by adding ?sc_mode=normal in the query string.
In the file system, go to every folder that corresponds to the URL path of your page. Look for a site.config file and if you find one, see what sites are defined there. loginPage may be missing from such a site definition, and if Sitecore finds one, it is not going to look at the main <sites> section in the Web.config.
Try adding ?sc_site=website to your query string in order to enforce the Sitecore.Context.Site to point to the right <site> definition.
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>
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.
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.
I have a Sitecore project with multiple websites where the Preview option is not working like expected. When i'm on an item with a presentation and click on Preview in the presentation tab i get the following error:
The requested document was not found ->
Requested URL: /sitecore/content/<WebnameXXX>/home
User Name: default\Anonymous
Site Name: website
If the page you are trying to display exists, please check that an appropriate prefix has been added to the IgnoreUrlPrefixes setting in the web.config.
What can I do to solve this issue?
I'm currently using 2 website nodes in the web.config file.
Web.config site nodes:
<site name="ggxxx_exxx1" hostName="ggxxx1.exxx.nl" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/gxxx1_nl" language="nl-NL" startItem="/home" database="web" domain="extranet" allowDebug="false" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableAnalytics="true" enableDebugger="false" disableClientData="false" />
<site name="ggxxx_exxx2" hostName="ggxxx2.exxx.nl" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/ggxxx2_nl" language="nl-NL" startItem="/home" database="web" domain="extranet" allowDebug="false" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableAnalytics="true" enableDebugger="false" disableClientData="false" />
Looks like your site definition is slightly off
/sitecore/content --//--- home
(double slash)