开发者

how to remove sitecore folder name in the url?

I created a sitecore year/month/day folder structure in the content tree, when i view each article under the folder node, the url could be http://local/landing/year/month/day/article1.aspx, how could I make the url like this: http://local/l开发者_高级运维anding/article1.aspx? just remove the year/month/day structure in the url.

Is there some function in sitecore like remove or hide special templates in the frontend url ?

Any help , Thanks .


You can do it in 2 ways:

  1. Use IIS 7 Url rewrite module to change the url. This way the url will be rewritten before it gets to sitecore and you don't need to change any code. You can find more info at the iis website

  2. You can create a custom Item resolver and add it to the RequestBegin sitecore pipeline. Alex Shyba wrote about it here.


It sounds like you may have thousands of these items, but even so, you may want to use the built in functionality of Sitecore and consider creating aliases for each of these items. Programmatically creating an the alias on an ItemSaved event or ItemCreated is probably easiest.


As @marto and @seth have said, you can use URL rewriting or aliases to solve this.

There is, however, a drawback to doing this, irrespective of how you choose to do it.

If you have very many items (your structure makes it sound like you may do) then either method will require that the URL is unique. Removing the date structure from the URL means that all items in your landing section will require unique URLs (whether inherited from their item names or by some other means). This can impact on SEO for your site, as authors may have difficulty finding an unused name that is also human readable and good for SEO. It's unlikely you want to use ugly GUIDs in your URLs.


2 options

  1. Change Bucket configuration and the set the required folder structure, bucket configuration can be found in Sitecore.Buckets.config file

  2. Extend GetFromRouteValue Item Resolver and overwrite the ResolveItem() method to get the bucket item. The default GetFromRouteValue class reference can be found in Sitecore.MVC.config file and replace this with your own customized implementation.

We have implemented with customized routing and getting the exact item if the route path matches.

Thanks, Jisha

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜