How to Properly Enable Special Characters like 'æ', 'ø' and 'å' in Your Optimizely Solution

Allowing special characters such as ‘æ’, ‘ø’, and ‘å’ in your Optimizely solution is simple. Optimizely provides a helpful article on this topic here:
https://support.optimizely.com/hc/en-us/articles/115005062883-Enable-special-characters-in-URL-Segment

However, do not blindly follow the steps in that article, as this will lead to unexpected results with your URLs.

AI-generated illustration: Avoid unnecessary characters in the URL

For CMS 12, all you need to do is update your UrlSegmentOptions configuration as follows:

var validChars = "ü ö ä ß ó ñ á á é í ó ő ú ü ñ æ ø å";
services.Configure<UrlSegmentOptions>(config => {
    config.SupportIriCharacters = true;
    config.ValidCharacters = @"A-Za-z0-9\-_~\.\$" + validChars;
}); 

And then add this code to Startup.cs.

For CMS 11, you have to make a simple InitializableModule that is described in the article linked above.

Avoiding Issues with URL Formatting

After implementing the above, the specified characters will work correctly in your Optimizely page URLs. However, if you include spaces in the validChars string like its says in the article, your URLs will look messy, with spaces represented as %20:

https://localhost:5000/test-page/new%20page%20with%20å/

The fix is straightforward: remove all spaces from the validChars string:

var validChars = "üöäßóñááéíóőúüñæøå";

With this adjustment, the resulting URL will look clean and professional:

https://localhost:5000/test-page/new-page-with-å/

AI-generated illustration