How to rewrite or shorten Sitecore URLs

I have a Sitecore site with the URL http://www.abc.com/our-resorts/resort1/career.aspx But I want to shorten the URL like http://www.abc.com/resort1/career .aspx . Any idea how to remove our-resortsfrom the url.

enter image description here

Please, any of the Sitecore community help me ....

thanks

+4
source share
2 answers

The first answer that comes to my mind is to use custom LinkProvider(to generate URLs on the site) and custom ItemResolver(to solve issues when a shortened URL occurs).

  • MyLinkProvider, Sitecore.Links.LinkProvider GetItemUrl. url /our-resorts/, our-resorts. , , our-resorts, . Sitecore.config LinkProvider .
  • MyItemResolver, HttpRequestProcessor, <httpRequestBegin> ItemResolver. :
public class ItemResolver : HttpRequestProcessor
{
    public override void Process(HttpRequestArgs args)
    {
        if (Context.Item != null || Context.Database == null || args.Url.ItemPath.Length == 0)
            return;
        string path = "/our-resorts" + MainUtil.DecodeName(args.Url.ItemPath);
        Context.Item =  args.GetItem(path);
    }
}

, . , .

+13

, URL Sitecore.
.

Sitecore, , , /our-resorts/resort1/career URL /resort1/career

enter image description here

+2

All Articles