Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions docs/general/ad-filtering/create-own-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,40 +536,24 @@ If you want the rule not to be applied to certain domains, start a domain name w

**`$domain` modifier matching target domain:**

In some cases the `$domain` modifier can match not only the referrer domain, but also the target domain. This happens when all the following conditions are met:
In some cases the `$domain` modifier can match not only the referrer domain, but also the target domain.

1. The request has the `document` content type
1. The rule pattern does not match any particular domains
1. The rule pattern does not contain regular expressions
1. The `$domain` modifier contains only excluded domains, e.g. `$domain=~example.org|~example.com`
This happens when the rule has one of the following modifiers: [`$cookie`](#cookie-modifier), [`$csp`](#csp-modifier), [`$permissions`](#permissions-modifier), [`$removeparam`](#removeparam-modifier).

The following predicate should be satisfied to perform a target domain matching:

```text
1 AND ((2 AND 3) OR 4)
```

That is, if the modifier `$domain` contains only excluded domains, then the rule does not need to meet the second and third conditions to match the target domain against the modifier `$domain`.

If some of the conditions above are not met but the rule contains [`$cookie`](#cookie-modifier) or [`$csp`](#csp-modifier) modifier, the target domain will still be matched.

If the referrer matches a rule with `$domain` that explicitly excludes the referrer domain, then the rule will not be applied even if the target domain also matches the rule. This affects rules with [`$cookie`](#cookie-modifier) and [`$csp`](#csp-modifier) modifiers, too.
For these modifiers, if the referrer matches a rule with `$domain` that explicitly excludes the referrer domain, then the rule will not be applied even if the target domain also matches the rule.

**Examples**

- `*$cookie,domain=example.org|example.com` will block cookies for all requests to and from `example.org` and `example.com`.
- `*$document,domain=example.org|example.com` will block all requests to and from `example.org` and `example.com`.
- `*$document,domain=example.org|example.com` will block requests only from `example.org` and `example.com` but not to them.

In the following examples it is implied that requests are sent from `http://example.org/page` (the referrer) and the target URL is `http://targetdomain.com/page`.

- `page$domain=example.org` will be matched, as it matches the referrer domain.
- `page$domain=targetdomain.com` will be matched, as it matches the target domain and satisfies all requirements mentioned above.
- `||*page$domain=targetdomain.com` will not be matched, as the pattern `||*page` may match specific domains,
e.g. `example.page`.
- `page$domain=targetdomain.com` will not be matched, as it does not match referrer domain.
- `||*page$domain=targetdomain.com,cookie` will be matched because the rule contains `$cookie` modifier
despite the pattern `||*page` may match specific domains.
- `/banner\d+/$domain=targetdomain.com` will not be matched as it contains a regular expression.
- `page$domain=targetdomain.com|~example.org` will not be matched because the referrer domain is explicitly excluded.
- `page$domain=targetdomain.com|~example.org,cookie` will not be matched because the referrer domain is explicitly excluded.

##### `$domain` modifier limitations {#domain-modifier-limitations}

Expand Down