2017-07-26 68 views
1

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

ISSUE 我想有我们的博客类URL从

https://example.com/blog/-in-category/categories/automotive
变更为
https://example.com/blog/automotive
格式:[域]/[博客]/[类别]

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

威尔自定义博客分类标准评估器解决了我需要完成的任务(我不知道该怎么做)?

感谢您的帮助!

回答

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

+0

谢谢!在我的规则中添加了(preCondition =“IsHtml”)并且工作正常。谢谢。 –

2

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

首先将是一个获取所有类别和使用你想要的格式呈现的链接,例如BlogCategories小部件。 它只会生成一个链接类似于“/ blog/[category]”的类别列表。

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

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