---
title: "Add a custom rule to your configuration"
slug: "add-a-custom-rule-to-your-configuration"
abstract: "When using patch files to customize the Sitecore configuration you can use custom rules to control when settings are applied."
---
# Add a custom rule to your configuration

When you use [a patch file](https://doc.sitecore.com/xp/en/developers/103/platform-administration-and-architecture/use-a-patch-file-to-customize-the-sitecore-configuration.html "Use a patch file to customize the Sitecore configuration") 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:

    ```xml
    <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.