I have extended the Friendly Url Rewriter in one project to rewrite all URL:s following a specific pattern to a search page.
Search Engine Optimization (SEO) with Friendly URL Rewriter
Instead of having to use URL that looks like this:
http://www.example.com/Search.aspx?country=åland?type=hotel
We accept URL:s in a more friendly format and rewrite internally to the format above with parameters:
http://www.example.com/åland-hotel.html
There exists no file with that name on the server instead we recognize the pattern with a regular exception like this one:
^(?<country>.+)-(?<type>.+)\.html$
Google AdWords does not allow diacritic marks in URLS
Using letters with accents, rings and umlaut a url is not allowed with Google AdWords so we needed a generic matching algorithm that would both recognize “aland” and “åland” when comparing search parameters.
There is a nice Unicode function, String.Normalize(), that makes it very easy to transform unwanted characters into something allowed.
Fabrice wrote a snippet of code to transform Åäö to Aao that I used:
public static String RemoveDiacritics(string s)
{
string normalizedString = s.Normalize(NormalizationForm.FormD);
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < normalizedString.Length; i++)
{
char c = normalizedString[i];
if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)
stringBuilder.Append(c);
}
return stringBuilder.ToString();
}
-
Hi,
Could you please provide a code sample for the same
as I am trying urlrewriting by extending episerver urlrewriting but getting some issues.Any help will be really appreciated.
Many thanks,
Nick -
Hi,
I am overriding HttpUrlRewriteToInternal function and passing it the url that I need to be passed internally (not to be shown on the address bar)
but for some reason the url on my address bar is getting changed.Do i need to override some other function as well to avoid this happening.
Could you please help on this.
regards,
Nick -
Nick, if you’re interested in custom URL rewriting you could have a look at the following post on implementing a custom URL rewrite provider in EPiServer: http://labs.episerver.com/en/Blogs/Ted-Nyberg/Dates/112276/7/Implementing-a-custom-URL-rewrite-provider-for-EPiServer/
-
Try wReplace tool which removes diacritic:
http://wwidgets.com/us_wReplace.html
There is available replacement table for removing diacritics (accents), so you can test your solutions.

![Fredrik Haglund [Photo by: Kristina Sahlén]](http://blog.fredrikhaglund.se/wp-content/uploads/2010/03/fredrik200.jpg)

7 comments
Comments feed for this article
Trackback link: http://blog.fredrikhaglund.se/blog/2008/04/16/how-to-remove-diacritic-marks-from-strings/trackback/