We have the following rewrite rules in our config:

    <replace mode="on" find="&amp;" replaceWith=",-a-," />
    <replace mode="on" find="?" replaceWith=",-q-," />
    <replace mode="on" find="/" replaceWith=",-s-," />
    <replace mode="on" find="*" replaceWith=",-w-," />
    <replace mode="on" find="." replaceWith=",-d-," />
    <replace mode="on" find=":" replaceWith=",-c-," />
    <replace mode="on" find=" " replaceWith="-" />

However when I create new items with spaces, the urls have '%20's in them. There are no includes that are overwriting this. We did switch over to MVC renderings from Layouts a while back, could this have effected the url's?

  • How are your URLs being written? Are all URLs affected or only some? – Dan Sinclair Apr 15 '19 at 16:09
  • Ah, just checked, and no, it's only happening in one section of the site. What could be causing it to work in one place but not the other? – Levi Wallach Apr 15 '19 at 16:51
  • My guess is the way that those URLs are being written out to the page. Can you post the code where you are turning the Item into a URL? My guess is it's in there somewhere. – Dan Sinclair Apr 15 '19 at 16:56
  • You were right - it looks like we were rewriting the urls for this new section to account for making them shorter. We were using the name of the item to write the url... So, I've adde the necessary replacements and it's working now. Thanks! – Levi Wallach Apr 15 '19 at 17:37

Double-check the code where the URLs are being generated to ensure that you're using the LinkManager to generate your URLs and not simply the items' names or display names. This will ensure that the encodeNameReplacements are taken into account when generating the URLs.

  • Currently it seems to be using Sitecore.Context.RawUrl. – Levi Wallach Apr 15 '19 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.