Request a topic or
contact an Arke consultant
404-812-3123
Nicer Sitecore URL’s

Arke Systems Blog

Useful technical and business information straight from Arke.

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Archive

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2024

Nicer Sitecore URL’s

Sitecore has a concept for replacing special characters in a URL. By default, their config file isn’t set to translate spaces. So URLS like, http://www.arkesystems.com/Hello World.aspx translate to http://www.arkesystems.com/Hello%20World.aspx. For SEO purposes, its best to translate spaces. Add the following line to your Sitecore web.configs so the URL would translate to http://www.arkesystems.com/Hello-World.aspx.

<encodeNameReplacements>
    <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="-" />
</encodeNameReplacements>


Posted by Eric Stoll on Tuesday, May 18, 2010 10:32 AM
Permalink | Comments (1) | Post RSSRSS comment feed

Comments (1) -

Amy Winburn United States

Tuesday, May 18, 2010 11:02 AM

The above update will not work with a patch include since the space will be stripped out so the web.config has to be edited directly.

Sitecore also posted the following regarding doing this:

Underscore ('_') and dash ('-') are reserved characters and cannot be used in encodeNameReplacements.
For instance the following replace pattern entails disappearing of some content node tabs:
  <replace mode="on" find=" " replaceWith="_" />
As workaround you have to define replace string with other characters.
For instance:
<replace mode="on" find=" " replaceWith=",-sp-," />


But if you really want to use – instead of spaces (from another blog):

If you are using a specific character to get rid of spaces in url, you need to make sure that a cms user will not be able to create an item name having that character in. Easy way to factor this in is to include your character in the InvalidItemNameChars element in the web.config. In my implementation, I've changed that setting to :
<setting name="InvalidItemNameChars" value="\/:?&quot;&lt;&gt;|[]-/>