Sitefinity 博客 URL 格式

Sitefinity Blog URL Format

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

问题 我正在尝试将我们的博客类别从

更改为 URL

https://example.com/blog/-in-category/categories/automotive

https://example.com/blog/automotive
格式:[域]/[博客名称]/[类别]

我添加了自定义博客提供程序,可以访问具有上述格式的类别,但是,分层小部件仍然显示原始 url。 我确实添加了一个出站重写规则,它确实将小部件 URL 更新为正确的格式,但是,它杀死了 Sitefinity 后端(无法访问页面、博客 Post 内容)。 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>

尝试访问页面时后端出错:

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

感谢您的帮助!

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

第一个是获取所有类别并使用您想要的格式呈现链接,例如博客类别小部件。 它只会生成一个类别列表,其中包含类似“/blog/[category]”

的链接

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

这有点工作,但比 url 我认为重写规则要干净得多。

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

<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