Sitecore - 重写""到“-"在 url 中,但仍然允许破折号作为合法的项目名称 [英] Sitecore - rewrite " " to "-" in urls but still allow dashes as legal item names

查看:37
本文介绍了Sitecore - 重写""到“-"在 url 中,但仍然允许破折号作为合法的项目名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了六份关于在 Sitecore 中将空间重写为更友好的内容的指南,但所有这些指南都依赖于 Sitecore 的 <encodeNameReplacements/> 元素,该元素也反转了需要-" 作为名称的非法字符.

I've read a half dozen guides on rewriting spaces to something more friendly in Sitecore, but all of them rely on Sitecore's <encodeNameReplacements/> element which also reverses the replacement requiring "-" to be an illegal character for names.

问题在于我们应用程序的 url 在主机名中有一个-".Sitecore 将其重写为 404.

The problem with this is that the url of our application has a "-" in the hostname. Sitecore rewrites this resulting in a 404.

有没有人知道如何在不依赖 <encodeNameReplacements 并且仍然允许-"作为合法项目名称字符的情况下在 Sitecore 中进行此 url 重写?我们目前最好的想法是使用比普通的-"稍微复杂一些的东西,例如--"或_".这不是一个好主意,所以我很感激你们对此事的任何见解.

Does anyone have ideas on how to do this url rewriting in Sitecore without relying on <encodeNameReplacements and still allowing "-" as a legal item name character? Our current best idea is to use something slighty more complex than a plain "-" such as "--" or "_". This isn't a very good idea, so I'd appreciate any insight you guys have on the matter.

我们正在使用 Sitecore 6.5 运行多站点设置

We are running a multi-site setup with Sitecore 6.5

推荐答案

因此,如果我假设正确,您想用其他一些对 SEO 更友好的字符替换项目名称中的空格.无论您配置什么替换,您都需要在等式的两边应用转换(双关语).所以--"或_"将不得不成为非法的项目名称字符.

So, if I am assuming correctly, you want to replace spaces in item names with some other SEO-friendlier character. Whatever replacement you configure, you would need to apply the transformation on both sides of the equation (pun intended). So '--' or '_' will have to become illegal item name characters.

我通常认为这样做是个坏主意,宁愿让我的内容编辑人员确定其内容的确切网址.

I generally think it's a bad idea to do this and would rather have my content editors determine the exact urls to their content.

但是,如果您绝对需要将其作为一项规则来实施,那么其中一种解决方案是 实现自定义处理程序以更改您的真实项目名称,同时保留项目显示名称的原始形式.

But if you absolutely need to implement this as a rule, one of the solutions out there is to implement a custom handler to change your real item name while leaving the item display name in its original form.

希望这会有所帮助.

这篇关于Sitecore - 重写&quot;&quot;到“-"在 url 中,但仍然允许破折号作为合法的项目名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆