---
metadata:
  - name: generator
    content: Diplodoc Platform v5.55.0
alternate:
  - https://yandex.com/support/adfox/en/ad-inventory/codes/referer-templates.md
  - https://yandex.com/support/adfox/ru/ad-inventory/codes/referer-templates.md
  - href: en/ad-inventory/codes/referer-templates.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/adfox/en/llms.txt

# Referer templates

In each banner request, Adfox receives a page address called a referer.

This referer is then matched to the page templates configured for site sections with the **Dynamic definition by REFERER** option enabled, or to templates specified in URL-based targeting.

You cannot simultaneously specify different template types for the same object.

{% note info %}

For domains with non-Latin characters, use Punycode format. Example: сайт.рф → xn--80aswg.xn--p1ai.

{% endnote %}

## Organization \<standard> {#standart-template}

- The `*` symbol stands for a sequence of any characters of any length.
- You can only specify one template per line, a total of 30 lines are available.

The **standard** template type works well for sites with a simple structure. For example, there is a website like www.website.com with a logical structure of three sections specified in Adfox: **Home page**, **News**, and **Everything else**. The user can open the home page by typing one of the following in the browser's address bar:

```
website.com 
www.website.com 
http://www.website.com 
http://www.website.com/index.html
```

You can either list all possible options line by line or use templates:

```
*website.com
*website.com/index.html
```

The **News** section template looks like this:

```
*website.com/news/*
```

The **Other** section template is as follows:
```
*
```

The sections thus represent different pages of the site.

## Organization \<POSIX.2> {#posix-template}

{% note info %}

When setting up [URL targeting](https://yandex.com/support/adfox/en/targeting/url.md), the template name is **Regular expression**.

{% endnote %}

In this type of templates, you can use characters from POSIX regular expressions.

The template type is used for highly branched site structures, for example, with multiple home pages (a common case: separate home pages for specific cities) or when it's impossible to describe the structure using a standard template type.

Here's a **POSIX.2** template for home pages of www.website.com:

```
.*(((website.com|www.website.com)/{0,1})|((website.com)/(index.html)/{0,1}))$
```

- `.*` Any set of characters. If you don’t specify start or end characters, the string by default begins and ends with `.*`, so you don’t have to add `.*` at the beginning or end of the template.
- `^` The beginning of the string (if the beginning of the string is not specified, the URL may contain any characters at the beginning, that is, by default, the string starts with `.*`).
- `$` The end of the string (if the string is not finished, the URL may contain any characters at the end, that is, by default, the string ends with `.*`).
- `|` The OR condition.
- `()` We wrap each option in brackets.
- `\` Escaping special characters with a backslash (characters that are used when writing a POSIX expression, for example, `?` or `.`).
- `/{0,1}` the {0,1} construct means that the character preceding it may occur 0 or 1 time.


> Example POSIX.2
>
> ```
> homer-simpson-tv\.blog4ever\.com|forum\.rojadirecta\.org|^hidan\.eklablog\.com.*|^aniworld\.spb\.com\/.*\/adfox\/.*s$
> ```
> 
>
> Let's analyze a template in parts and see why these examples are suitable:
> 
> - `homer-simpson-tv\.blog4ever\.com`
>     
>   `http://homer-simpson-tv.blog4ever.com/?a=1212`: There is no start or end character at the beginning or end of the template, and, by default, a string may have any set of characters at the beginning and at the end.
> - `forum\.rojadirecta\.org`
>     
>   `https://www.forum.rojadirecta.org/?b=123`: There is no start or end character at the beginning or end of the template, and, by default a string may have any set of characters at the beginning and at the end.
>     
> - `^hidan\.eklablog\.com.*`
>     
>   `hidan.eklablog.com/?b=123`: The string starts with a start-of-string character, so the URL can't begin with any other characters. However, any construct may be used at the end of the string, after .com.
>     
> - `^aniworld\.spb\.com\/.*\/adfox\/.*s$`
> 
>
>    `aniworld.spb.ru/123/adfox/s`: There are limiting characters at the beginning and at the end of the string. However, after .ru, there may be any construct that is allowed by `.*`.


## How to check whether the page templates for the site sections are set up correctly {#checking}

You can determine which section a site page belongs to, if [Adfox site-level ad codes](https://yandex.com/support/adfox/en/ad-inventory/codes/get-code.md#site-code) are installed on it:

1. Copy the URL of the site page that you want to check.
1. In the Adfox interface, go to the **Inventory** tab. Select the site where you want to check the section settings.
1. In the **Sections** tab, paste the site page URL in the **Template URL** box and press **Enter**.

The system shows the section that the site page URL currently belongs to according to the available page templates.


<!-- source: en/_includes/feedback.md -->
## Contact support


<a href="en/form"> <!--ссылка, куда ведет кнопка. Если внутренняя ссылка, пишем без .md и .html --> 
  <span class="button">Send an email</span> <!--текст на кнопке--> 
</a>



<!-- source: en/_includes/styles/button.md -->

<!-- endsource: en/_includes/styles/button.md -->
<!-- endsource: en/_includes/feedback.md -->
