如何防止在任何语言标识下访问Sitecore内容?

时间:2016-04-06 03:25:37

标签: sitecore

如何删除在Sitecore中查找语言标识符下的内容的功能?

此处的内容:

/about

也可在以下网址找到:

/en/about

更奇怪的是,任何在不同的语言标识符下查找内容的尝试都会导致无法找到视图的错误。

/es/about
/pt-br/about
/aa/about  (this is invented..)

我不希望任何语言标识符下的内容可用 - 上面的网址应该只是404.

我无法找到隔离和处理此语言标识符的位置。我从LanguageResolver管道中删除了httpRequestBegin,但这并没有改变行为。

关于在LinkManager中关闭语言嵌入的博客文章很多,我已经完成了,但这还不够 - 我不希望在任何语言代码下生成内容。 URL的第一段应该像任何其他段一样对待。 /en/[whatever]的请求应为404。

2 个答案:

答案 0 :(得分:4)

除了将LinkManager设置为从不嵌入之外,您还需要将Languages.AlwaysStripLanguage设置为false

来源:http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2015/03/prevent-the-sitecore-aspnet-cms-from-interpreting-url-path-prefixes-as-language-names.aspx

答案 1 :(得分:0)

假设您已经安装了自定义404解析器,您只需将Sitecore设置Languages.AlwaysStripLanguagetrue更改为false,如下所示:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting name="Languages.AlwaysStripLanguage" value="false" /> 
    </settings>
  </sitecore>
</configuration>
相关问题