skip to Main Content

I am looking for guidance on an issue trying to change the blog url format to make the categories SEO friendly.

ISSUE
I am trying to have our blog categories URL changed from

https://example.com/blog/-in-category/categories/automotive
to
https://example.com/blog/automotive
Format: [domain]/[blogname]/[category]

I’ve added a custom blog provider and can access the categories with the above format, however, the hierarchical widget still shows the original url.
I did add an outbound rewrite rule that did update the widgets URLs to the correct format, however, it killed the Sitefinity backend (can’t access Pages, Blog Post Content). Scriptresource.axd and Webresource.axd through a 404.

Here is the out bound rule..

<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>

Errors from backend when trying to access the Pages:

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

Will a custom blog taxonomy evaluator solve what I am needing to accomplish (which I’m not sure how to do)?

Thanks for your help!

2

Answers


  1. I would probably create 2 custom MVC widgets that will handle this scenario:

    First would be one that gets all categories and renders the links using the format you want, e.g. BlogCategories widget.
    It will just generate a list of categories with links of the likes of “/blog/[category]”

    Second widget would be a blog list controller that will have the category as a parameter and will get all blog posts that have that category.

    It is a bit of work, but much cleaner than having url rewrite rules I think.

    Login or Signup to reply.
  2. In your case, problem is that you forgot to use precondition. Working example is:

    <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. But I am totally agree with @Veselin Vasilev, that cleaner approach is to build custom widget.

    You can find source code of built-in widgets here:

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

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search