2017-07-26 70 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重寫規則更清潔。