SEO Friendly Urls in Sitecore -Remove spaces in Url

by aboo bolaky 29. November 2008 09:50

Aliases in Sitecore

Sitecore has the concept of "Aliases", whereby each item can accessed using a specific name (rather than the default path). Aliases are turned on by default. To turn them off, you can flip the web.config settings name AliasesActive to false (But who would want to do that???? Sealed)

Space Characters in Sitecore

When you create an item in Sitecore, you free to choose the naming of your item (provided it succesfully validates against some key rules .e.g Item name cannot contain :,?.. otherwise, you will end up with a "Item xxx is not a valid name"). Most of the time, you will want to put spaces in the item name. Let's take an example:

If an item (at the root level) has an item name of "John Doe", the url of the actual page should theoretically be http://hostname/John%20Doe .

Of course, you can get rid of this spacing issue by specifying an Alias of John-Doe on the item itself. But imaging you having hundreds of items with spaces !!!..

The encodeNameReplacements element in the Web.config

This encodeNameReplacements settings allow you to globally replace any unwanted character in your url to a character of your choice. So, rather than creating an alias for each item (without spaces), we can add the following new setting.

<encodeNameReplacements>
	<replace mode="on" find="&" replaceWith=",-a-,"/> 
	<replace mode="on" find="?" replaceWith=",-q-,"/>
	.....
	<replace mode="on" find=" " replaceWith="-" />
</encodeNameReplacements> 

Job Done ! Cool

 

Tags:

.Net | Applications | Sitecore | Tips & Tricks

Comments

5/20/2010 7:11:44 PM #

Cheap Nike Shoes

Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information

Cheap Nike Shoes United States |

Tag cloud

Flash Player 9 required.

About Me

I wish I could write something here..
//TODO: ElaborateMe