Great tip for url replacing with Umbraco

By Markus Johansson
2014-08-01

As long as I can remember Umbraco has shipped with a set of presets for the url replacing feature. This is the feature that takes the node name and turns it into a valid url. These presets lives in the /config/umbracoSettings.config-file and used to look something like this.

<urlReplacing removeDoubleDashes="true">
   <char org=" ">-</char>
   <char org="""></char>
   <char org="."></char>
   <char org=";"></char>
   <char org="/"></char>
   <char org=":"></char>
   <char org="+">plus</char>
   <char org="*">star</char>
   <char org="&"></char>
   <char org="?"></char>
   <char org="æ">ae</char>
   <char org="ø">oe</char>
   <char org="å">aa</char>
</urlReplacing>

In later versions of Umbraco (I think since Umbraco 7) the urlReplacing element has been removed from the default umbracoSettings.config-file and the presets are hidden. At CodeGarden14 this year I learned very much from Stephans session about the core internals of Umbraco (Slides: http://www.zpqrtbnk.net/CoreInternalsForWebsiteDevelopment.pdf) one thing was the toAscii-property of the urlReplacing-element. Since there is hundreds of different chars that you might want to replace and it’s very likely that you’ll miss some – that why they have included this great little flag. So all the configuration above can be replaced with this simple line:

<requestHandler>
  ....
    <urlReplacing toAscii="true" />
</requestHandler>





More blog posts



15 januari 2021

Umbraco and MiniProfiler