Add a custom rule to your configuration

Current version: 9.3

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:

    RequestResponse
    <appSettings>
    
    <add key="localenv:define" value="QA">
    
    </appsettings>
  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.

Note

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.

Do you have some feedback for us?

If you have suggestions for improving this article,