Sam*_*Sam 4 url-rewriting sitecore sitecore7
我有Sitecore网站的网址
http://www.abc.com/our-resorts/resort1/career.aspx
但我想缩短网址,如
http://www.abc.com/resort1/career.aspx.知道如何our-resorts从URL中删除.

请Sitecore社区的任何人帮助我....
谢谢
Mar*_*lak 13
我想到的第一个答案是使用自定义LinkProvider(在网站上生成网址)和自定义ItemResolver(在缩短网址时解析项目).
MyLinkProvider继承Sitecore.Links.LinkProvider和覆盖GetItemUrl方法.如果网址包含/our-resorts/,请删除our-resorts.当然,这假设您没有具有名称的项目,这些项目our-resorts在链接生成中不应该被省略.用LinkProvider新的标准替换Sitecore.config标准.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);
}
}
Run Code Online (Sandbox Code Playgroud)
我没有编译或测试代码,所以你需要自己测试它.如果您还有其他问题,请在下面发布.