> ## Documentation Index
> Fetch the complete documentation index at: https://gcore-doc-1894.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a rule manually or from a template to configure settings for particular files

The **Rules** section overrides CDN options for specific files — independently of the Resource Settings that apply to all files by default. Each rule matches files by URI pattern or regular expression and applies its own option set to those files only, with a maximum of five rules per CDN resource.

As an example: [CDN caching settings](/cdn/cdn-resource-options/cache/specify-cache-lifetime-on-a-cdn-resource-or-origin) are enabled for a resource with the CDN-controlled option, which applies to all files. To apply Origin-Controlled to specific files instead, create a rule for those paths and add the Origin-Controlled option — CDN-Controlled then applies everywhere except the paths covered by the rule.

The **Rules** tab shows how many rules have been created for the resource.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image1.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=566d64942433ce87abc9307ff1e77cf4" alt="Rules section with rule count and Create rule button" width="1272" height="283" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image1.png" />
</Frame>

## Add rules in the customer portal

Rules are added from the **Rules** tab of any CDN resource. Each rule can be built from scratch or created from a template.

### Create a rule manually

1\. In the Resource settings, navigate to the **Rules** tab. Click **Create rule** and select **Create blank rule** from the drop-down list.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image2.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=1f63b764645bb71cd1d4d805fa5f1e10" alt="Create a rule manually" width="487" height="316" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image2.png" />
</Frame>

A new page will open. Follow the remaining steps on that page.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image3.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=0e3d25a2358b6c10eac52357a71f3ebf" alt="Create a rule manually" width="604" height="684" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image3.png" />
</Frame>

2\. Enter the rule name.

3\. Specify the path to the file or folder to which the rule applies. The path must start with `^/` or `/` and cannot contain the origin domain name. Specify a URI or use [regular expressions (regex)](https://en.wikipedia.org/wiki/Regular_expression).

<Note>
  If a URI matches multiple rules, the rule that appears first in the order is applied. For instance, if the resource has two rules — `/folder/.*` (first) and `/folder/image.jpg` (second) — the first rule applies to `/folder/image.jpg`.
</Note>

4\. If the CDN resource has multiple origin groups, select the required group from the **Origins Group** list.

5\. Select the protocol that the CDN resource will use to pull the files specified in step three. If files are accessible over the same protocol as the origin, select **Inherit from resource**. If not, select the appropriate option: HTTP, HTTPS, or both protocols at once.

6\. Click the **Add option** button to configure options if necessary. A panel opens with the list of available options — click an option name to add it to the rule. When done, close the panel.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image4.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=579b13bcb4242c1f76a6be6baf16720e" alt="Add option panel with available CDN options" width="678" height="697" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image4.png" />
</Frame>

There are three variants for how the options in the Rules sections interact with the options in the Resource Settings:

| Variant                                         | Interaction method                                          | Example                                                                                                                                                                                                                                                                                                                                                                                                |
| ----------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Options are not added to the rule               | Option parameters are inherited from the Resource settings  | CDN caching is enabled in the Resource settings and the rule contains no CDN caching option — caching parameters for the files in the rule are inherited from the Resource settings.                                                                                                                                                                                                                   |
| An option is added to the rule, but is disabled | Option parameters from the Resource Settings are disabled   | The [Country access policy](/cdn/cdn-resource-options/security/control-access-to-the-content-with-country-referrer-ip-and-user-agents-policies#country-access-policy) option is enabled with Allow by default and DE in the Resource settings, blocking access to content in Germany. A rule with the disabled Country access policy option means that files in the rule remain accessible in Germany. |
| An option is added to the rule and enabled      | Option parameters from the Resource Settings are overridden | [Browser caching](/cdn/cdn-resource-options/cache/specify-cache-lifetime-for-user-browsers) is set to CDN-Controlled, 4 days in the Resource settings. A rule with Browser caching set to 30 minutes overrides that for the files in the rule — they are cached in the browser for 30 minutes while other files are cached for 4 days.                                                                 |

7\. Click **Create rule**.

### Create a rule from a template

Templates allow a fixed set of options to be reused across multiple CDN resources. Five system templates are available — Video segments (.ts), Playlists (.m3u8), Let's Encrypt HTTP-01 challenge, Static content, and Image optimization — and custom templates can be created from any saved rule. Full details are in the [templates guide](/cdn/cdn-resource-options/rules-for-particular-files/create-a-cdn-resource-rule-template-manually-or-use-a-system-one).

To create a rule from a template:

1\. In the Resource settings, navigate to the **Rules** tab. Click **Create rule**. In the dropdown, select **Create blank rule** to build a rule from scratch, or select a template name under **Create from system templates** to use a system template, or select a custom template created earlier.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image2.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=1f63b764645bb71cd1d4d805fa5f1e10" alt="Create rule dropdown showing system templates and custom templates" width="487" height="316" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image2.png" />
</Frame>

2\. A form opens with pre-filled settings from the template. Review the settings and edit them if needed — the steps in [Create a rule](#create-a-rule-manually) apply.

3\. Click **Create rule**.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image5.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=d4d7a2844dc224a8b5c51facc90bacfe" alt="Create rule from template form with pre-filled settings" width="688" height="728" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image5.png" />
</Frame>

## Examples of rules

The following examples show how rules can be used to override specific CDN options for a subset of files.

### Prohibit caching for static files

To prohibit CDN caching for JPG, CSS, and JS files:

* Enter **`^/.*\.(jpg|css|js)$`** to the Rule pattern field.
* Add the CDN caching option with the "CDN Controlled" and "Do not cache" values.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image6.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=4339966242a522d73f1a953dcda7b068" alt="CDN caching disabled for static files matching the pattern" width="686" height="850" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image6.png" />
</Frame>

### Set Access-Control-Allow-Origin for .ttf files

To set up the Access-Control-Allow-Origin HTTP header only for files with the .ttf extension:

* Enter **`/.*\.ttf$`** to the Rule pattern field.
* Add the CORS header support option.
* Configure which domains the header applies to — [CORS header support](/cdn/cdn-resource-options/http-headers/add-the-access-control-allow-origin-header-to-the-browser-response) explains the available options.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image7.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=a4b58a4b52c0ec812102664fa031886e" alt="Set Access-Control-Allow-Origin for .ttf files" width="780" height="732" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image7.png" />
</Frame>

## Suspend, activate, or delete a rule

Rules can be suspended when not needed — for testing purposes or before deletion. Suspended rules do not apply to the specified files but still count toward the rule limit.

To suspend a rule:

1\. Navigate to the **Rules** tab and click the rule name to open its settings.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image1.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=566d64942433ce87abc9307ff1e77cf4" alt="Rules section with rule name link" width="1272" height="283" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image1.png" />
</Frame>

2\. In the **Rule availability** section, uncheck **Enable rule**. A confirmation dialog appears — click **Yes, suspend**.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image8.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=ab8c520ea843525f0a1a5408c8fdcb79" alt="Rule availability section with Enable rule checkbox unchecked" width="561" height="378" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image8.png" />
</Frame>

To activate a suspended rule, click the rule name, check **Enable rule**, and click **Save changes**.

Suspended rules have a **Suspended** status and active rules have an **Active** status in the rules list.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image9.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=64832b911f147de2ff482e605b8340ca" alt="Suspended status and Active status in the rules list" width="1104" height="410" data-path="images/docs/cdn/cdn-resource-options/rules-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files/create-a-rule-manually-or-from-a-template-to-configure-settings-for-particular-files-image9.png" />
</Frame>

Alternatively, use the three-dot menu next to any rule in the list. For active rules, the menu provides **Suspend rule** — clicking it opens the same confirmation dialog. For suspended rules, the menu provides **Activate rule** — clicking it activates the rule immediately, without a confirmation dialog.

The three-dot menu also provides **Edit** to open the rule settings, **Save as template** to create a template from the current rule configuration, and **Delete rule** to delete the rule. Only suspended rules can be deleted.

To delete a rule:

1\. Suspend the rule (see above).

2\. Click the three-dot menu next to the suspended rule and select **Delete rule**.

3\. Click **Yes, delete** to confirm.
