<!-- review: finished -->

<a id="http-browser"></a>

# Browser

The module creates variables whose values depend on the value of the `User-Agent` request header field.

<a id="variables"></a>

## Variables

<a id="v-modern-browser"></a>

### `$modern_browser`

equals the value set by the [modern_browser_value](#modern-browser-value) directive, if a browser was identified as modern;

<a id="v-ancient-browser"></a>

### `$ancient_browser`

equals the value set by the [ancient_browser_value](#ancient-browser-value) directive, if a browser was identified as ancient;

<a id="v-msie"></a>

### `$msie`

equals "1" if a browser was identified as MSIE of any version.

<a id="configuration-example-9"></a>

## Configuration Example

<a id="choosing-an-index-file"></a>

### Choosing an index file:

```nginx
modern_browser_value "modern.";

modern_browser msie      5.5;
modern_browser gecko     1.0.0;
modern_browser opera     9.0;
modern_browser safari    413;
modern_browser konqueror 3.0;

index index.${modern_browser}html index.html;
```

<a id="redirection-for-old-browsers"></a>

### Redirection for old browsers:

```nginx
modern_browser msie      5.0;
modern_browser gecko     0.9.1;
modern_browser opera     8.0;
modern_browser safari    413;
modern_browser konqueror 3.0;

modern_browser unlisted;

ancient_browser Links Lynx netscape4;

if ($ancient_browser) {
    rewrite ^ /ancient.html;
}
```

<a id="directives-10"></a>

## Directives

<a id="index-0"></a>

<a id="id4"></a>

### ancient_browser

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `ancient_browser` string ...;   |
|------------------------------------------------------------------------------------------|---------------------------------|
| Default                                                                                  | —                               |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location          |

If any of the specified substrings is found in the `User-Agent` request header field, the browser will be considered ancient. The special string "netscape4" corresponds to the regular expression "^Mozilla/[1-4]".

<a id="index-1"></a>

<a id="ancient-browser-value"></a>

### ancient_browser_value

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `ancient_browser_value` string;   |
|------------------------------------------------------------------------------------------|-----------------------------------|
| Default                                                                                  | `ancient_browser_value 1;`        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location            |

Sets a value for the [$ancient_browser](#v-ancient-browser) variable.

<a id="index-2"></a>

<a id="id7"></a>

### modern_browser

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `modern_browser` browser version;<br/><br/>`modern_browser` `unlisted`;   |
|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| Default                                                                                  | —                                                                         |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                                                    |

Specifies a version starting from which a browser is considered modern. A
browser can be any one of the following: `msie`, `gecko` (browsers
based on Mozilla), `opera`, `safari`, or `konqueror`.

Versions can be specified in the following formats: X, X.X, X.X.X, or X.X.X.X. The maximum values for each of the formats are 4000, 4000.99, 4000.99.99, and 4000.99.99.99, respectively.

The special value `unlisted` specifies to consider a browser as modern if it was not listed by the modern_browser and [ancient_browser](#id4) directives. Otherwise such a browser is considered ancient. If a request does not provide the `User-Agent` field in the header, the browser is treated as not being listed.

<a id="index-3"></a>

<a id="modern-browser-value"></a>

### modern_browser_value

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `modern_browser_value` string;   |
|------------------------------------------------------------------------------------------|----------------------------------|
| Default                                                                                  | `modern_browser_value 1;`        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location           |

Sets a value for the [$modern_browser](#v-modern-browser) variable.
