Mercurial > hg > nginx-site
annotate xml/en/docs/http/ngx_http_rewrite_module.xml @ 801:b95a6d779c89
Documented that "listen ... ssl" is preferred over "ssl on".
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 27 Dec 2012 17:16:39 +0000 |
parents | 6b6585577c33 |
children | 9fce700e56d3 |
rev | line source |
---|---|
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1 <?xml version="1.0"?> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
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 |
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
9 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
10 <module name="Module ngx_http_rewrite_module" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
11 link="/en/docs/http/ngx_http_rewrite_module.html" |
589 | 12 lang="en" |
702
6b6585577c33
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
13 rev="3"> |
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
14 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
15 <section id="summary"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
16 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
17 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
18 The <literal>ngx_http_rewrite_module</literal> module allows to |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
19 change URIs using regular expressions, return redirects, and |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
20 conditionally select configurations. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
21 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
22 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
23 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
24 The <literal>ngx_http_rewrite_module</literal> module directives are |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
25 processed in the following order: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
26 <list type="bullet"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
27 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
28 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
29 the directives of this module specified on the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
30 <link doc="ngx_http_core_module.xml" id="server"/> level are processed; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
31 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
32 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
33 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
34 a location for a request is searched; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
35 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
36 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
37 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
38 the directives of this module specified in the selected |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
39 <link doc="ngx_http_core_module.xml" id="location"/> are processed, |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
40 and if they changed a URI, a new location is searched for the new URI. |
674
c48c0936b4df
Documented internal redirections limit.
Vladimir Homutov <vl@nginx.com>
parents:
673
diff
changeset
|
41 This cycle may be repeated up to |
c48c0936b4df
Documented internal redirections limit.
Vladimir Homutov <vl@nginx.com>
parents:
673
diff
changeset
|
42 <link doc="ngx_http_core_module.xml" id="internal">10 times</link> |
c48c0936b4df
Documented internal redirections limit.
Vladimir Homutov <vl@nginx.com>
parents:
673
diff
changeset
|
43 after which the error <http-status code="500" text="Internal Server Error"/> |
c48c0936b4df
Documented internal redirections limit.
Vladimir Homutov <vl@nginx.com>
parents:
673
diff
changeset
|
44 is returned. |
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
45 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
46 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
47 </list> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
48 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
49 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
50 </section> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
51 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
52 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
53 <section id="directives" name="Directives"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
54 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
55 <directive name="break"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
56 <syntax/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
57 <default/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
58 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
59 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
60 <context>if</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
61 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
62 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
63 Stops processing the current set of |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
64 <literal>ngx_http_rewrite_module</literal> directives. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
65 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
66 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
67 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
68 Example: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
69 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
70 if ($slow) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
71 limit_rate 10k; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
72 break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
73 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
74 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
75 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
76 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
77 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
78 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
79 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
80 <directive name="if"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
81 <syntax block="yes">(<value>condition</value>)</syntax> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
82 <default/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
83 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
84 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
85 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
86 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
87 The specified <value>condition</value> is evaluated. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
88 If true, the directives of this module specified inside the braces are |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
89 executed, and a request is assigned the configuration inside the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
90 <literal>if</literal> directive. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
91 Configurations inside the <literal>if</literal> directives are |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
92 inherited from the previous configuration level. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
93 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
94 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
95 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
96 A condition may be any of the following: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
97 <list type="bullet"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
98 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
99 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
100 a variable name; false if the value of a variable is an empty string |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
101 or any string starting with “<literal>0</literal>”; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
102 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
103 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
104 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
105 comparing a variable with a string using the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
106 “<literal>=</literal>” and “<literal>!=</literal>” operators; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
107 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
108 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
109 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
110 matching a variable against a regular expression using the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
111 “<literal>~</literal>” (for case-sensitive matching) and |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
112 “<literal>~*</literal>” (for case-insensitive matching) operators. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
113 Regular expressions can contain captures that are made available for |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
114 later reuse in the <var>$1</var>..<var>$9</var> variables. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
115 Negative operators “<literal>!~</literal>” and “<literal>!~*</literal>” |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
116 are also available. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
117 If a regular expression includes the characters “<literal>}</literal>” |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
118 or “<literal>;</literal>”, the whole expressions should be enclosed |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
119 in single or double quotes. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
120 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
121 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
122 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
123 checking a file existence with the “<literal>-f</literal>” and |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
124 “<literal>!-f</literal>” operators; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
125 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
126 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
127 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
128 checking a directory existence with the “<literal>-d</literal>” and |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
129 “<literal>!-d</literal>” operators; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
130 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
131 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
132 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
133 checking a file, directory, or symbolic link existence with the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
134 “<literal>-e</literal>” and “<literal>!-e</literal>” operators; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
135 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
136 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
137 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
138 checking for an executable file with operators “<literal>-x</literal>” |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
139 and “<literal>!-x</literal>” operators. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
140 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
141 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
142 </list> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
143 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
144 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
145 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
146 Examples: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
147 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
148 if ($http_user_agent ~ MSIE) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
149 rewrite ^(.*)$ /msie/$1 break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
150 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
151 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
152 if ($http_cookie ~* "id=([^;]+)(?:;|$)") { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
153 set $id $1; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
154 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
155 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
156 if ($request_method = POST) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
157 return 405; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
158 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
159 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
160 if ($slow) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
161 limit_rate 10k; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
162 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
163 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
164 if ($invalid_referer) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
165 return 403; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
166 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
167 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
168 <note> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
169 A value of the embedded variable <var>$invalid_referer</var> is set by the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
170 <link doc="ngx_http_referer_module.xml" id="valid_referers"/> directive. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
171 </note> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
172 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
173 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
174 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
175 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
176 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
177 <directive name="return"> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
178 <syntax><value>code</value> [<value>text</value>]</syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
179 <syntax><value>code</value> <value>URL</value></syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
180 <syntax><value>URL</value></syntax> |
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
181 <default/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
182 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
183 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
184 <context>if</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
185 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
186 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
187 Stops processing and returns the specified <value>code</value> to a client. |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
188 The non-standard code 444 closes a connection without sending |
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
189 a response header. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
190 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
191 |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
192 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
193 Starting from version 0.8.42, it is possible to specify |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
194 either the URL of redirect (for codes 301, 302, 303, and 307), |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
195 or the <value>text</value> of a response body (for other codes). |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
196 A response body text or URL of redirect can contain variables. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
197 As a special case, a URL of redirect can be specified as a URI |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
198 local to this server, in which case the full URL of redirect |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
199 is formed according to the request scheme (<var>$scheme</var>) and the |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
200 <link doc="ngx_http_core_module.xml" id="server_name_in_redirect"/> and |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
201 <link doc="ngx_http_core_module.xml" id="port_in_redirect"/> directives. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
202 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
203 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
204 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
205 In addition, a <value>URL</value> for temporary redirect with the code 302 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
206 can be specified as the sole parameter. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
207 Such a parameter should start with the string “<literal>http://</literal>”, |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
208 “<literal>https://</literal>”, or “<literal>$scheme</literal>”. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
209 A <value>URL</value> can contain variables. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
210 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
211 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
212 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
213 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
214 Only the following codes could be returned before version 0.7.51: |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
215 204, 400, 402 — 406, 408, 410, 411, 413, 416, and 500 — 504. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
216 </note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
217 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
218 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
219 The code 307 was not treated as a redirect until versions 1.1.16 and 1.0.13. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
220 </note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
221 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
222 |
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
223 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
224 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
225 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
226 <directive name="rewrite"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
227 <syntax> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
228 <value>regex</value> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
229 <value>replacement</value> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
230 [<value>flag</value>]</syntax> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
231 <default/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
232 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
233 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
234 <context>if</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
235 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
236 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
237 If the specified regular expression matches a URI, the URI is changed |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
238 as specified in the <value>replacement</value> string. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
239 The <literal>rewrite</literal> directives are executed sequentially |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
240 in order of their appearance in the configuration file. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
241 Flags make it possible to terminate further processing of directives. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
242 If a replacement string starts with “<literal>http://</literal>” |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
243 or “<literal>https://</literal>”, the processing stops and a |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
244 redirect is returned to a client. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
245 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
246 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
247 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
248 An optional <value>flag</value> parameter can be one of: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
249 <list type="tag"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
250 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
251 <tag-name><literal>last</literal></tag-name> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
252 <tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
253 stops processing the current set of |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
254 <literal>ngx_http_rewrite_module</literal> directives |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
255 followed by a search for a new location matching the changed URI; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
256 </tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
257 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
258 <tag-name><literal>break</literal></tag-name> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
259 <tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
260 stops processing the current set of |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
261 <literal>ngx_http_rewrite_module</literal> directives; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
262 </tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
263 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
264 <tag-name><literal>redirect</literal></tag-name> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
265 <tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
266 returns a temporary redirect with the code 302; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
267 used if a replacement string does not start with |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
268 “<literal>http://</literal>” or “<literal>https://</literal>”; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
269 </tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
270 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
271 <tag-name><literal>permanent</literal></tag-name> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
272 <tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
273 returns a permanent redirect with the code 301. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
274 </tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
275 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
276 </list> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
277 The full URL of redirects is formed according to the |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
278 request scheme (<var>$scheme</var>) and the |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
279 <link doc="ngx_http_core_module.xml" id="server_name_in_redirect"/> and |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
280 <link doc="ngx_http_core_module.xml" id="port_in_redirect"/> directives. |
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
281 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
282 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
283 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
284 Example: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
285 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
286 server { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
287 ... |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
288 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
289 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
290 return 403; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
291 ... |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
292 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
293 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
294 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
295 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
296 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
297 But if these directives are put inside the “<literal>/download/</literal>” |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
298 location, the <literal>last</literal> flag should be replaced by |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
299 <literal>break</literal>, otherwise nginx will make 10 cycles and |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
300 return the error 500: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
301 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
302 location /download/ { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
303 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
304 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
305 return 403; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
306 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
307 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
308 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
309 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
310 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
311 If a <value>replacement</value> string includes the new request arguments, |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
312 the previous request arguments are appended after them. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
313 If this is undesired, putting a question mark at the end of a replacement |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
314 string avoids having them appended, for example: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
315 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
316 rewrite ^/users/(.*)$ /show?user=$1? last; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
317 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
318 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
319 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
320 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
321 If a regular expression includes the characters “<literal>}</literal>” |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
322 or “<literal>;</literal>”, the whole expressions should be enclosed |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
323 in single or double quotes. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
324 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
325 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
326 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
327 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
328 |
673
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
329 <directive name="rewrite_log"> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
330 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
331 <default>off</default> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
332 <context>http</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
333 <context>server</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
334 <context>location</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
335 <context>if</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
336 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
337 <para> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
338 Enables or disables logging of <literal>ngx_http_rewrite_module</literal> |
702
6b6585577c33
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
339 module directives processing results |
6b6585577c33
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
340 into the <link doc="../ngx_core_module.xml" id="error_log"/> at |
673
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
341 the <literal>notice</literal> level. |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
342 </para> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
343 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
344 </directive> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
345 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
346 |
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
347 <directive name="set"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
348 <syntax><value>variable</value> <value>value</value></syntax> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
349 <default/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
350 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
351 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
352 <context>if</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
353 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
354 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
355 Sets a <value>value</value> for the specified <value>variable</value>. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
356 A <value>value</value> can contain text, variables, and their combination. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
357 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
358 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
359 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
360 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
361 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
362 <directive name="uninitialized_variable_warn"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
363 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
364 <default>on</default> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
365 <context>http</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
366 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
367 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
368 <context>if</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
369 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
370 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
371 Controls whether warnings about uninitialized variables are logged. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
372 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
373 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
374 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
375 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
376 </section> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
377 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
378 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
379 <section id="internals" name="Internal Implementation"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
380 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
381 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
382 The <literal>ngx_http_rewrite_module</literal> module directives |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
383 are compiled during the configuration stage into internal instructions |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
384 that are interpreted during request processing. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
385 An interpreter is a simple virtual stack machine. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
386 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
387 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
388 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
389 For example, the directives |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
390 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
391 location /download/ { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
392 if ($forbidden) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
393 return 403; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
394 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
395 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
396 if ($slow) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
397 limit_rate 10k; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
398 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
399 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
400 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
401 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
402 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
403 will be translated into these instructions: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
404 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
405 variable $forbidden |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
406 check against zero |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
407 return 403 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
408 end of code |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
409 variable $slow |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
410 check against zero |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
411 match of regular expression |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
412 copy "/" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
413 copy $1 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
414 copy "/mp3/" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
415 copy $2 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
416 copy ".mp3" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
417 end of regular expression |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
418 end of code |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
419 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
420 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
421 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
422 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
423 Note that there are no instructions for the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
424 <link doc="ngx_http_core_module.xml" id="limit_rate"/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
425 directive above as it is unrelated to the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
426 <literal>ngx_http_rewrite_module</literal> module. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
427 A separate configuration is created for the <link id="if"/> block. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
428 If the condition holds true, a request is assigned this configuration |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
429 where <literal>limit_rate</literal> equals to 10k. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
430 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
431 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
432 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
433 The directive |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
434 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
435 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
436 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
437 can be made smaller by one instruction if the first slash in the regular expression |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
438 is put inside the parentheses: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
439 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
440 rewrite ^(<emphasis>/</emphasis>download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
441 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
442 The corresponding instructions will then look like this: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
443 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
444 match of regular expression |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
445 copy $1 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
446 copy "/mp3/" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
447 copy $2 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
448 copy ".mp3" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
449 end of regular expression |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
450 end of code |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
451 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
452 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
453 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
454 </section> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
455 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
456 </module> |