BLOG  ›  2008  ›  11  ›  15  ›  Url Rewriting in Umbraco - Friendly Tag Filter
Url Rewriting in Umbraco - Friendly Tag Filter
Samstag, 15. November 2008, Christoph Ertl

After finishing the Tag Cloud package the next step to improve my web site was to get rid of the ugly query URLs when filtering blog posts by tag.

The Goal

Instead of

/blog.aspx?filterBy=TagName

I wanted something like

/blog/tag/TagName

Why ?

  1. As we all - techies of course - know search engines are not happy with URLs like this
  2. I also had the impression that Google AdSense didn't distinguish the pages correctly.
  3. I personally don't like URLs containing query parameters on a web page as they are not user friendly.
  4. Some kind of perfectionism

The Solution

It's that simple that I was not sure if it's being worth posting. But it took me a while to find the solution. Like in most cases. It's easy if you know where and how to do it. It would be easier if the feature would be mentioned in the feature list or online help. However, here it is:

In the file /config/UrlRewriting.config one can place rules for rewriting URLs. Just add a rule like this.

<add name="tagfilter"
  virtualUrl="^~/blog/tag/(.*).aspx"

 
rewriteUrlParameter="ExcludeFromClientQueryString"
  destinationUrl="~/blog.aspx?filterBy=$1"

 
ignoreCase="true"

/>

A detailed description how it works can be found in the file itself.

One important thing is that without reconfiguring the IIS Server the URL must end up with .aspx. So the new URL looks like this

/blog/tag/TagName.aspx

which is very straight forward as all other nodes are also referenced using the aspx extension.

References

  • This Umbraco feature is powered by the ASP.NET UrlRewritingNet component which can be found at http://www.urlrewriting.net/
  • A Post where the feature is at least mentioned.
  • A Post from Warren where he points to some problems using this feature.


0 Kommentare für “Url Rewriting in Umbraco - Friendly Tag Filter”

    Leave a comment


    Not shown. Will only display your Gravatar picture from http://www.gravatar.com/


    (optional - remember http://)


    Enter the characters from the image. (used to avoid spam posts)