Sitefinity博客URL格式

时间:2017-07-26 19:21:35

标签: sitefinity

我正在寻找有关尝试更改博客网址格式以使SEO类别友好的问题的指导。

ISSUE 我正在尝试更改我们的博客类别网址

https://example.com/blog/-in-category/categories/automotive
https://example.com/blog/automotive
格式:[域名] / [blogname] / [category] ​​

我添加了自定义博客提供程序,可以使用上述格式访问类别,但是,分层小部件仍然显示原始网址。 我确实添加了一个出站重写规则,它确实将窗口小部件URL更新为正确的格式,然而,它杀死了Sitefinity后端(无法访问Pages,Blog Post Content)。 Scriptresource.axd和Webresource.axd通过404.

这是出界规则..

<outboundRules>
               <rule name="Cat Rewrite Rule">
                    <match filterByTags="A" pattern="/blog/-in-category/categories/([^$]+)" />
                     <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{URL}" pattern="\.axd" negate="true" />
          </conditions>

                 <action type="Rewrite" value="/blog/{R:1}" />

                </rule>

              <preConditions>
                <preCondition name="IsHtml">
                  <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html"/>
                </preCondition>
              </preConditions>
 </outboundRules>

尝试访问页面时来自后端的错误:

Error From Backend When trying to access pages/blog/events etc

自定义博客分类评估器是否会解决我需要完成的任务(我不知道该怎么做)?

感谢您的帮助!

2 个答案:

答案 0 :(得分:3)

在您的情况下,问题是您忘记使用前置条件。工作示例是:

<outboundRules>
     <rule name="Cat Rewrite Rule" preCondition="IsHtml">
        <match filterByTags="A" pattern="/blog/-in-category/categories/([^$]+)" />
        <action type="Rewrite" value="/blog/{R:1}" />
     </rule>
     <preConditions>
         <preCondition name="IsHtml">
              <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html"/>
         </preCondition>
     </preConditions>
</outboundRules>

P.S。但我完全同意@Veselin Vasilev,更清晰的方法是构建自定义小部件。

您可以在此处找到内置小部件的源代码:

博客:https://github.com/Sitefinity/feather-widgets/tree/master/Telerik.Sitefinity.Frontend.Blogs

分类:https://github.com/Sitefinity/feather-widgets/tree/master/Telerik.Sitefinity.Frontend.Taxonomies

答案 1 :(得分:2)

我可能会创建2个自定义MVC小部件来处理这种情况:

首先是获取所有类别并使用您想要的格式呈现链接的链接,例如: BlogCategories小部件。 它只会生成一个类别列表,其中包含&#34; / blog / [category]&#34;

等链接

第二个小部件将是一个博客列表控制器,它将该类别作为参数,并将获得具有该类别的所有博客帖子。

这是一项工作,但比我想的url重写规则更清晰。

相关问题