Replace special characters including space in page URL’s with a dash (-) in Sitefinity

Problem Statement

When you create a new page using Sitefinity CMS backend and puts title of the page, Sitefinity automatically generates URL for that page using the given title.

For Example – You give the title of the new page e.g.  test@page the URL will create like this /test@page



Now question is “How to configure Sitefinity to exclude special characters (including space) from the page URL and replace them with a dash (-) when generating the URL from the page title?”



Solution


To convert all of these types of special characters including space to dash (-), you can use the regular expression.

In order to configure how page URL’s are generated from the page title when creating the page using Sitefinity backend, Follow the below steps –

Step 1. Login to Sitefinity backend using your credentials.

Step 2. Click on “Administration” menu and go to “Settings” -> click “Advanced” and scroll down to “System” in left navigation bar and expand the System -> Site URL Settings -> URLRulesClient

Step 3. In the right pane, go to RegularExpressionFilter textbox and put the below regular expression and put dash (-) in “Replace With” textbox.

            [^a-zA-Z0-9_]+



Step 4. Click save.

After saving this configuration, changes would be effected immediately and now on putting any special character (table mentioned below) in the title of the page, URL would be converted to dash.

List of special characters which would be converted to dash (-) after applying above given regular expression - 



Special Character
Is replaced by -
`
yes
~
yes
@
Yes
#
Yes
%
Yes
^
Yes
&
Yes
*
Yes
(
Yes
)
Yes
+
Yes
=
Yes
!
Yes
\
Yes
/
Yes
|
Yes
]
Yes
[
Yes
{
Yes
}
Yes
'
Yes
"
Yes
;
Yes
:
Yes
?
Yes
.
Yes
> 
Yes
< 
Yes
,
Yes


Write to me in the comment box in case you need any help or you have any questions or concerns related to Sitefinity CMS. Have a good day!









No comments:

Post a Comment