2
votes

Is there anyone here who has successfully removed sitecore/content from Sitecore's generated URLs.

I'm using Sitecore link manager to generate the URLs. I have a multi site setup and have enabled the Siteresolving option to true. However, it seems that there is no way to get this to work using the Link Manager.

GetFriendlyUrl methods seems to generate the URL without sitecore/content but unfortunately it's deprecated, so it's not an option here.

I've seen people suggesting overwriting the LinkProvider and write custom logic to remove sitecore/content from the URLs. This works but not a good solution really.

I would love to learn from other Sitecore experts here.

FYI: I'm using Sitecore 6.4.

Cheers!

3
Could you paste <sites> and <linkManager> from the sitecore config? - Marek Musielak
Could you paste how you use LinkProvider as well? - Marek Musielak
Read Mark's blog post. You most likely have something set incorrectly in the <sites> section. - Bryan

3 Answers

4
votes

Please ensure your sites are configured correctly from this blog post: Have '/sitecore/content' in your URLs? Time to fix it.

3
votes

I've found the solution. My multi-site configuration was correct as per Mark's reference. What I did to fix the issue was to specify the site context to use when generating the links.

Sitecore.Links.UrlOptions URLOptions = new Sitecore.Links.UrlOptions();
URLOptions.Site = Sitecore.Configuration.Factory.GetSite(Your_Site_Name);
return Sitecore.Links.LinkManager.GetItemUrl(ThisItem, URLOptions);
0
votes

fyi, I found it the following snippet useful for identifying the correct context site for my scenario where content for one site context was referenced from another site context. I'm planning on updating the canonical link to notify google of the correct url.

public static Sitecore.Web.SiteInfo GetSite(this Sitecore.Data.Items.Item itemYouNeedToCheck)
{
return Sitecore.Configuration.Factory.GetSiteInfoList()
    .OrderByDescending(x=> x.RootPath.Length)
    .FirstOrDefault(x => x.Database!="core" &&    itemYouNeedToCheck.Paths.FullPath.StartsWith(x.RootPath));
}