Configure forbidden URL characters
In URLs, some characters are considered unsafe because they may be used for special purposes or could cause issues with browsers or servers. The system automatically replaces or removes forbidden characters in URL slugs and vanity URLs.
By default, the following characters are forbidden:
\/:*?"<>|&%.'#[]+=„“ and the space and tab characters
Specify additional forbidden characters
To specify additional forbidden characters:
- Open the Settings application.
- Select the URLs and SEO category.
- Type the characters into the Forbidden URL characters setting (without any separator).
- Save the settings.
Alternatively, you can enter a regular expression into the Allowed URL characters setting to precisely specify which characters are allowed in URLs.
Override default forbidden characters
The default characters listed above are always forbidden unless you override the CMSForbiddenURLValues
key in your project’s configuration file (appsettings.json by default). For example:
"CMSForbiddenURLValues": "\\/:*?\"<>|&%.'#[]+ ="
Note: Support for the slash (‘/’) character in vanity URLs always requires additional configuration, even if the slash character is not included in the forbidden characters specified by the CMSForbiddenURLValues
key.
You can either use the key to allow some of the default forbidden characters or add new ones. We strongly recommend keeping the default set of forbidden characters – entering the characters into URL values may prevent certain types of URLs from resolving correctly.
Allow the slash (‘/’) character in vanity URLs
Support for the slash character in vanity URLs can’t be configured through the CMSForbiddenURLValues
key, but has to be enabled separately. When the setting below is enabled, the slash character is always allowed in vanity URLs, regardless of other settings.
To allow the slash character in vanity URLs:
- Open the Settings application.
- Select the URLs and SEO category.
- Select the Allow ‘/’ in vanity URLs setting.
- Save the settings.
Note:
The following vanity URL paths are always forbidden:
- paths starting with ‘/’ or ‘~/’
- paths ending with ‘/’
- paths containing multiple ‘/’ in a row (e.g.,
vanity//path
)
Specify forbidden character replacement
To specify forbidden character replacement:
- Open the Settings application.
- Select the URLs and SEO category.
- Enter the character into the Forbidden character replacement setting.
- Save the settings.
By default, forbidden characters located at the beginning or end of the path are removed completely and consecutive forbidden characters are only replaced by a single replacement character. For example, “Articles*and%%%blogs” is replaced with “Articles-and-blogs” when using the default replacement character: ‘-’ hyphen. If no replacement character is specified, the underscore ‘_’ character is used.