Add a custom rule to your configuration

Last updated Friday, October 13, 2017 in Sitecore Experience Platform for Administrator, Developer
Keywords: Configuration

When you use a patch file to customize the Sitecore configuration, you can use custom rules to determine the conditions under which the configuration settings in the patch file are applied.

With custom rules, you can use the same patch files on different Sitecore instances, and just change the rules in the web.config file in order to enable different configurations on the individual instance.

To define a custom rule:

  1. In the web.config file, in the <appSettings> section, add a line specifying the rule. For example, the following adds a rule named localenv and assigns the value QA to it:
    <add key="localenv:define" value="QA">
  2. To specify multiple values, enter the values separated by commas. For example, the following assigns the values QA, Test, and Development to the localenv rule:

    <add key="localenv:define" value="QA,Test,Development">

Rule values are not case sensitive. However, it is best practice to use the same case whenever a key is referenced.

If the rule contains multiple values, you must separate the values with commas.


When Sitecore reads the rule definition, it ignores any blank spaces between the individual values. For example, QA, Test and QA,Test are both valid.

Send feedback about the documentation to