Path: blob/main/xml/en/docs/http/ngx_http_browser_module.xml
1 views
<?xml version="1.0"?>12<!--3Copyright (C) Igor Sysoev4Copyright (C) Nginx, Inc.5-->67<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">89<module name="Module ngx_http_browser_module"10link="/en/docs/http/ngx_http_browser_module.html"11lang="en"12rev="2">1314<section id="summary">1516<para>17The <literal>ngx_http_browser_module</literal> module creates variables18whose values depend on the value of the <header>User-Agent</header>19request header field:20<list type="tag">2122<tag-name id="var_modern_browser"><var>$modern_browser</var></tag-name>23<tag-desc>24equals the value set by the <link id="modern_browser_value"/> directive,25if a browser was identified as modern;26</tag-desc>2728<tag-name id="var_ancient_browser"><var>$ancient_browser</var></tag-name>29<tag-desc>30equals the value set by the <link id="ancient_browser_value"/> directive,31if a browser was identified as ancient;32</tag-desc>3334<tag-name id="var_msie"><var>$msie</var></tag-name>35<tag-desc>36equals “1” if a browser was identified as MSIE of any version.37</tag-desc>3839</list>40</para>4142</section>434445<section id="example" name="Example Configuration">4647<para>48Choosing an index file:49<example>50modern_browser_value "modern.";5152modern_browser msie 5.5;53modern_browser gecko 1.0.0;54modern_browser opera 9.0;55modern_browser safari 413;56modern_browser konqueror 3.0;5758index index.${modern_browser}html index.html;59</example>60</para>6162<para>63Redirection for old browsers:64<example>65modern_browser msie 5.0;66modern_browser gecko 0.9.1;67modern_browser opera 8.0;68modern_browser safari 413;69modern_browser konqueror 3.0;7071modern_browser unlisted;7273ancient_browser Links Lynx netscape4;7475if ($ancient_browser) {76rewrite ^ /ancient.html;77}78</example>79</para>8081</section>828384<section id="directives" name="Directives">8586<directive name="ancient_browser">87<syntax><value>string</value> ...</syntax>88<default/>89<context>http</context>90<context>server</context>91<context>location</context>9293<para>94If any of the specified substrings is found in the <header>User-Agent</header>95request header field, the browser will be considered ancient.96The special string “<literal>netscape4</literal>” corresponds to the97regular expression “<literal>^Mozilla/[1-4]</literal>”.98</para>99100</directive>101102103<directive name="ancient_browser_value">104<syntax><value>string</value></syntax>105<default>1</default>106<context>http</context>107<context>server</context>108<context>location</context>109110<para>111Sets a value for the <var>$ancient_browser</var> variables.112</para>113114</directive>115116117<directive name="modern_browser">118<syntax><value>browser</value> <value>version</value></syntax>119<syntax><literal>unlisted</literal></syntax>120<default/>121<context>http</context>122<context>server</context>123<context>location</context>124125<para>126Specifies a version starting from which a browser is considered modern.127A browser can be any one of the following: <literal>msie</literal>,128<literal>gecko</literal> (browsers based on Mozilla),129<literal>opera</literal>, <literal>safari</literal>,130or <literal>konqueror</literal>.131</para>132133<para>134Versions can be specified in the following formats: X, X.X, X.X.X, or X.X.X.X.135The maximum values for each of the format are1364000, 4000.99, 4000.99.99, and 4000.99.99.99, respectively.137</para>138139<para>140The special value <literal>unlisted</literal> specifies to consider141a browser as modern if it was not listed by the142<literal>modern_browser</literal> and <link id="ancient_browser"/>143directives.144Otherwise such a browser is considered ancient.145If a request does not provide the <header>User-Agent</header> field146in the header, the browser is treated as not being listed.147</para>148149</directive>150151152<directive name="modern_browser_value">153<syntax><value>string</value></syntax>154<default>1</default>155<context>http</context>156<context>server</context>157<context>location</context>158159<para>160Sets a value for the <var>$modern_browser</var> variables.161</para>162163</directive>164165</section>166167</module>168169170