Mercurial > hg > nginx-site
annotate xml/ru/docs/http/ngx_http_rewrite_module.xml @ 2913:a20b51e84c32
Linux packages: actualized supported Alpine Linux versions.
author | Konstantin Pavlov <thresh@nginx.com> |
---|---|
date | Fri, 25 Nov 2022 11:13:56 +0400 |
parents | dd78dd9e2cb7 |
children |
rev | line source |
---|---|
222
bfe3eff81d04
Removed redundant encoding specification.
Ruslan Ermilov <ru@nginx.com>
parents:
110
diff
changeset
|
1 <?xml version="1.0"?> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
580
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
548
diff
changeset
|
3 <!-- |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
548
diff
changeset
|
4 Copyright (C) Igor Sysoev |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
548
diff
changeset
|
5 Copyright (C) Nginx, Inc. |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
548
diff
changeset
|
6 --> |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
548
diff
changeset
|
7 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 |
382 | 10 <module name="Модуль ngx_http_rewrite_module" |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 link="/ru/docs/http/ngx_http_rewrite_module.html" |
589 | 12 lang="ru" |
2057
dd78dd9e2cb7
Corrected directive processing order in the rewrite module.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1964
diff
changeset
|
13 rev="9"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
110
40eec261c2a6
Added proper support for anonymous sections, notably for the summary.
Ruslan Ermilov <ru@nginx.com>
parents:
108
diff
changeset
|
15 <section id="summary"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 <para> |
382 | 18 Модуль <literal>ngx_http_rewrite_module</literal> позволяет |
1723
065978f4ece1
Added info about PCRE in the rewrite module.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1061
diff
changeset
|
19 изменять URI запроса с помощью регулярных выражений PCRE, делать перенаправления |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
20 и выбирать конфигурацию по условию. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
21 </para> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
22 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
23 <para> |
2057
dd78dd9e2cb7
Corrected directive processing order in the rewrite module.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1964
diff
changeset
|
24 Директивы <link id="break"/>, <link id="if"/>, <link id="return"/>, |
dd78dd9e2cb7
Corrected directive processing order in the rewrite module.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1964
diff
changeset
|
25 <link id="rewrite"/> и <link id="set"/> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
26 обрабатываются в следующем порядке: |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
27 <list type="bullet"> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
28 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
29 <listitem> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
30 последовательно выполняются директивы этого модуля, описанные на уровне |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
31 <link doc="ngx_http_core_module.xml" id="server"/>; |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
32 </listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
33 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
34 <listitem> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
35 в цикле: |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
36 <list type="bullet"> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
37 |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
38 <listitem> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
39 ищется |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
40 <link doc="ngx_http_core_module.xml" id="location"/> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
41 по URI запроса; |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
42 </listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
43 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
44 <listitem> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
45 последовательно выполняются директивы этого модуля, |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
46 описанные в найденном location; |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
47 </listitem> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
48 |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
49 <listitem> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
50 цикл повторяется, если URI запроса <link id="rewrite">изменялся</link>, |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
51 но не более |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
52 <link doc="ngx_http_core_module.xml" id="internal">10 раз</link>. |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
53 </listitem> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
54 |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
55 </list> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
56 </listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
57 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
58 </list> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 </section> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 |
382 | 64 <section id="directives" name="Директивы"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 <directive name="break"> |
102
c76a257f3fd4
The directive name is now automatically printed in <default> and <syntax>.
Ruslan Ermilov <ru@nginx.com>
parents:
99
diff
changeset
|
67 <syntax/> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
68 <default/> |
382 | 69 <context>server</context> |
70 <context>location</context> | |
71 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 <para> |
382 | 74 Завершает обработку текущего набора директив модуля |
75 <literal>ngx_http_rewrite_module</literal>. | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 <para> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
79 Если директива указана внутри |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
80 <link doc="ngx_http_core_module.xml" id="location"/>, |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
81 дальнейшая обработка запроса продолжается в этом location. |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
82 </para> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
83 |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
84 <para> |
382 | 85 Пример: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 <example> |
382 | 87 if ($slow) { |
88 limit_rate 10k; | |
89 break; | |
90 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 <directive name="if"> |
108
72524ae53106
Explicitly marked directives with the block syntax. Such directives will
Ruslan Ermilov <ru@nginx.com>
parents:
106
diff
changeset
|
98 <syntax block="yes">(<value>условие</value>)</syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
99 <default/> |
382 | 100 <context>server</context> |
101 <context>location</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
104 Проверяется указанное <value>условие</value>. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
105 Если оно истинно, то выполняются указанные в фигурных скобках директивы |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
106 этого модуля и запросу назначается конфигурация, указанная внутри |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
107 директивы <literal>if</literal>. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
108 Конфигурации внутри директив <literal>if</literal> наследуются с |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
109 предыдущего уровня конфигурации. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 В качестве условия могут быть заданы: |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 <list type="bullet"> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 <listitem> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
117 имя переменной; ложными значениями переменной являются пустая строка |
860
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
118 или “<literal>0</literal>”; |
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
119 <note> |
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
120 До версии 1.0.1 ложным значением также являлась любая строка, |
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
121 начинающаяся на “<literal>0</literal>”. |
861 | 122 </note> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 <listitem> |
382 | 126 сравнение переменной со строкой с помощью операторов |
127 “<literal>=</literal>” и “<literal>!=</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 <listitem> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
131 соответствие переменной регулярному выражению с учётом |
382 | 132 регистра символов — “<literal>~</literal>” и без него — “<literal>~*</literal>”. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 В регулярных выражениях можно использовать выделения, которые затем |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
134 доступны в виде переменных <var>$1</var>..<var>$9</var>. |
382 | 135 Также можно использовать отрицательные операторы “<literal>!~</literal>” |
136 и “<literal>!~*</literal>”. | |
137 Если в регулярном выражении встречаются символы “<literal>}</literal>” | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
138 или “<literal>;</literal>”, то всё выражение следует заключить в одинарные |
382 | 139 или двойные кавычки. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 <listitem> |
382 | 143 проверка существования файла с помощью операторов “<literal>-f</literal>” |
144 и “<literal>!-f</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 <listitem> |
382 | 148 проверка существования каталога с помощью операторов “<literal>-d</literal>” |
149 и “<literal>!-d</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 <listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 проверка существования файла, каталога или символической ссылки |
382 | 154 с помощью операторов “<literal>-e</literal>” и “<literal>!-e</literal>”; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 <listitem> |
382 | 158 проверка исполняемости файла с помощью операторов “<literal>-x</literal>” |
159 и “<literal>!-x</literal>”. | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 </list> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
165 <para> |
382 | 166 Примеры: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
167 <example> |
382 | 168 if ($http_user_agent ~ MSIE) { |
169 rewrite ^(.*)$ /msie/$1 break; | |
170 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 |
382 | 172 if ($http_cookie ~* "id=([^;]+)(?:;|$)") { |
173 set $id $1; | |
174 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 |
382 | 176 if ($request_method = POST) { |
177 return 405; | |
178 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 |
382 | 180 if ($slow) { |
181 limit_rate 10k; | |
182 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 |
382 | 184 if ($invalid_referer) { |
185 return 403; | |
186 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
188 <note> |
382 | 189 Значение встроенной переменной <var>$invalid_referer</var> задаётся директивой |
106
56457a474903
If text of the link is not provided, the @id is used.
Ruslan Ermilov <ru@nginx.com>
parents:
102
diff
changeset
|
190 <link doc="ngx_http_referer_module.xml" id="valid_referers"/>. |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
191 </note> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
196 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
197 <directive name="return"> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
198 <syntax><value>код</value> [<value>текст</value>]</syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
199 <syntax><value>код</value> <value>URL</value></syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
200 <syntax><value>URL</value></syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
201 <default/> |
382 | 202 <context>server</context> |
203 <context>location</context> | |
204 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
205 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
206 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
207 Завершает обработку и возвращает клиенту указанный <value>код</value>. |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
208 Нестандартный код 444 закрывает соединение без передачи |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
209 заголовка ответа. |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
210 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
211 |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
212 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
213 Начиная с версии 0.8.42 можно задать |
1964
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
214 либо URL перенаправления (для кодов 301, 302, 303, 307 и 308) |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
215 либо <value>текст</value> тела ответа (для остальных кодов). |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
216 В тексте тела ответа и URL перенаправления можно использовать переменные. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
217 Как частный случай, URL перенаправления может быть задан как URI, |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
218 локальный для данного сервера, при этом полный URL перенаправления |
966 | 219 формируется согласно схеме запроса (<var>$scheme</var>) и директивам |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
220 <link doc="ngx_http_core_module.xml" id="server_name_in_redirect"/> и |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
221 <link doc="ngx_http_core_module.xml" id="port_in_redirect"/>. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
222 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
223 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
224 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
225 Кроме того, в качестве единственного параметра можно указать |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
226 <value>URL</value> для временного перенаправления с кодом 302. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
227 Такой параметр должен начинаться со строк “<literal>http://</literal>”, |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
228 “<literal>https://</literal>” или “<literal>$scheme</literal>”. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
229 В <value>URL</value> можно использовать переменные. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
230 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
231 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
232 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
233 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
234 До версии 0.7.51 можно было возвращать только следующие коды: |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
235 204, 400, 402 — 406, 408, 410, 411, 413, 416 и 500 — 504. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
236 </note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
237 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
238 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
239 До версий 1.1.16 и 1.0.13 код 307 не обрабатывался как перенаправление. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
240 </note> |
1964
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
241 |
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
242 <note> |
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
243 До версии 1.13.0 код 308 не обрабатывался как перенаправление. |
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
244 </note> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
245 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
246 |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
247 <para> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
248 См. также директиву <link doc="ngx_http_core_module.xml" id="error_page"/>. |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
249 </para> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
250 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
251 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
252 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
253 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
254 <directive name="rewrite"> |
382 | 255 <syntax> |
256 <value>regex</value> | |
257 <value>замена</value> | |
258 [<value>флаг</value>]</syntax> | |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
259 <default/> |
382 | 260 <context>server</context> |
261 <context>location</context> | |
262 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
263 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
264 <para> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
265 Если указанное регулярное выражение соответствует URI запроса, URI изменяется |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
266 в соответствии со строкой замены. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
267 Директивы <literal>rewrite</literal> выполняются последовательно, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
268 в порядке их следования в конфигурационном файле. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
269 С помощью флагов можно прекратить дальнейшую обработку директив. |
1873
2f851f71ff08
Documented $scheme support in the "rewrite" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
1723
diff
changeset
|
270 Если строка замены начинается с “<literal>http://</literal>”, |
2f851f71ff08
Documented $scheme support in the "rewrite" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
1723
diff
changeset
|
271 “<literal>https://</literal>” или “<literal>$scheme</literal>”, |
2f851f71ff08
Documented $scheme support in the "rewrite" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
1723
diff
changeset
|
272 то обработка завершается и клиенту возвращается перенаправление. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
274 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
275 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
276 Необязательный параметр <value>флаг</value> может быть одним из: |
382 | 277 <list type="tag"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
278 |
382 | 279 <tag-name><literal>last</literal></tag-name> |
280 <tag-desc> | |
281 завершает обработку текущего набора директив модуля | |
282 <literal>ngx_http_rewrite_module</literal>, | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
283 после чего ищется новый location, соответствующий изменённому URI; |
382 | 284 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
285 |
382 | 286 <tag-name><literal>break</literal></tag-name> |
287 <tag-desc> | |
288 завершает обработку текущего набора директив модуля | |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
289 <literal>ngx_http_rewrite_module</literal> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
290 аналогично директиве <link id="break"/>; |
382 | 291 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
292 |
382 | 293 <tag-name><literal>redirect</literal></tag-name> |
294 <tag-desc> | |
295 возвращает временное перенаправление с кодом 302; | |
296 используется, если заменяющая строка не начинается с | |
1873
2f851f71ff08
Documented $scheme support in the "rewrite" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
1723
diff
changeset
|
297 “<literal>http://</literal>”, “<literal>https://</literal>” |
2f851f71ff08
Documented $scheme support in the "rewrite" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
1723
diff
changeset
|
298 или “<literal>$scheme</literal>”; |
382 | 299 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
300 |
382 | 301 <tag-name><literal>permanent</literal></tag-name> |
302 <tag-desc> | |
303 возвращает постоянное перенаправление с кодом 301. | |
304 </tag-desc> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
305 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
306 </list> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
307 Полный URL перенаправлений формируется согласно |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
308 схеме запроса (<var>$scheme</var>) и директив |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
309 <link doc="ngx_http_core_module.xml" id="server_name_in_redirect"/> и |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
310 <link doc="ngx_http_core_module.xml" id="port_in_redirect"/>. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
311 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
312 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
313 <para> |
382 | 314 Пример: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
315 <example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
316 server { |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
317 ... |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
318 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
319 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
320 return 403; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
321 ... |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
322 } |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
323 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
324 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
325 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
326 <para> |
382 | 327 Если же эти директивы поместить в location “<literal>/download/</literal>”, |
328 то нужно заменить флаг <literal>last</literal> на <literal>break</literal>, | |
329 иначе nginx сделает 10 циклов и вернёт ошибку 500: | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
330 <example> |
382 | 331 location /download/ { |
332 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; | |
333 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra break; | |
334 return 403; | |
335 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
336 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
337 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
338 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
339 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
340 Если в строке замены указаны новые аргументы запроса, то предыдущие |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
341 аргументы запроса добавляются после них. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
342 Если такое поведение нежелательно, можно отказаться от этого добавления, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
343 указав в конце строки замены знак вопроса, например: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
344 <example> |
382 | 345 rewrite ^/users/(.*)$ /show?user=$1? last; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
346 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
347 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
348 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
349 <para> |
382 | 350 Если в регулярном выражении встречаются символы “<literal>}</literal>” |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
351 или “<literal>;</literal>”, то всё выражение следует заключить в одинарные |
382 | 352 или двойные кавычки. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
353 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
354 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
355 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
356 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
357 |
673
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
358 <directive name="rewrite_log"> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
359 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
360 <default>off</default> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
361 <context>http</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
362 <context>server</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
363 <context>location</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
364 <context>if</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
365 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
366 <para> |
703
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
367 Разрешает или запрещает записывать в |
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
368 <link doc="../ngx_core_module.xml" id="error_log"/> |
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
369 на уровне <literal>notice</literal> |
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
370 результаты обработки директив модуля <literal>ngx_http_rewrite_module</literal>. |
673
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
371 </para> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
372 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
373 </directive> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
374 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
375 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
376 <directive name="set"> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
377 <syntax><value>$переменная</value> <value>значение</value></syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
378 <default/> |
382 | 379 <context>server</context> |
380 <context>location</context> | |
381 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
382 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
383 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
384 Устанавливает значение указанной переменной. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
385 В качестве значения можно использовать текст, переменные и их комбинации. |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
386 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
387 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
388 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
389 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
390 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
391 <directive name="uninitialized_variable_warn"> |
271 | 392 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
102
c76a257f3fd4
The directive name is now automatically printed in <default> and <syntax>.
Ruslan Ermilov <ru@nginx.com>
parents:
99
diff
changeset
|
393 <default>on</default> |
382 | 394 <context>http</context> |
395 <context>server</context> | |
396 <context>location</context> | |
397 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
398 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
399 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
400 Определяет, нужно ли писать в лог предупреждения о неинициализированных |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
401 переменных. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
402 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
403 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
404 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
405 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
406 </section> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
407 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
408 |
382 | 409 <section id="internals" name="Внутреннее устройство"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
410 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
411 <para> |
382 | 412 Директивы модуля <literal>ngx_http_rewrite_module</literal> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
413 компилируются на стадии конфигурации во внутренние инструкции, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
414 интерпретируемые во время обработки запроса. |
382 | 415 Интерпретатор представляет из себя простую стековую виртуальную машину. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
416 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
417 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
418 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
419 Например, директивы |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
420 <example> |
382 | 421 location /download/ { |
422 if ($forbidden) { | |
423 return 403; | |
424 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
425 |
382 | 426 if ($slow) { |
427 limit_rate 10k; | |
428 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
429 |
382 | 430 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
431 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
432 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
433 будут транслированы в такие инструкции: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
434 <example> |
382 | 435 переменная $forbidden |
436 проверка на ноль | |
437 возврат 403 | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
438 завершение всего кода |
382 | 439 переменная $slow |
440 проверка на ноль | |
441 проверка регулярного выражения | |
442 копирование "/" | |
443 копирование $1 | |
444 копирование "/mp3/" | |
445 копирование $2 | |
446 копирование ".mp3" | |
447 завершение регулярного выражения | |
448 завершение всего кода | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
449 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
450 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
451 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
452 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
453 Обратите внимание, что инструкций для директивы |
382 | 454 <link doc="ngx_http_core_module.xml" id="limit_rate"/> |
455 нет, поскольку она не имеет отношения к модулю | |
456 <literal>ngx_http_rewrite_module</literal>. | |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
457 Для блока <link id="if"/> создаётся отдельная конфигурация. |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
458 Если условие истинно, запрос получает эту конфигурацию, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
459 и в ней <literal>limit_rate</literal> равен 10k. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
460 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
461 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
462 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
463 Директиву |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
464 <example> |
382 | 465 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
466 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
467 можно сделать на одну инструкцию меньше, если в регулярном выражении перенести |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
468 первый слэш внутрь скобок: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
469 <example> |
382 | 470 rewrite ^(<emphasis>/</emphasis>download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
471 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
472 Тогда соответствующие инструкции будут выглядеть так: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
473 <example> |
382 | 474 проверка регулярного выражения |
475 копирование $1 | |
476 копирование "/mp3/" | |
477 копирование $2 | |
478 копирование ".mp3" | |
479 завершение регулярного выражения | |
480 завершение всего кода | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
481 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
482 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
483 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
484 </section> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
485 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
486 </module> |