Mercurial > hg > nginx-site
annotate xml/en/docs/http/ngx_http_rewrite_module.xml @ 580:be54c443235a
Added copyright markers to documentation sources.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Tue, 10 Jul 2012 12:59:42 +0000 |
parents | 95a970603b0f |
children | 764fbac1b8b4 |
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" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
12 lang="en"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
13 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
14 <section id="summary"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
15 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
16 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
17 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
|
18 change URIs using regular expressions, return redirects, and |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
19 conditionally select configurations. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
20 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
21 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
22 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
23 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
|
24 processed in the following order: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
25 <list type="bullet"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
26 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
27 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
28 the directives of this module specified on the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
29 <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
|
30 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
31 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
32 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
33 a location for a request is searched; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
34 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
35 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
36 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
37 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
|
38 <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
|
39 and if they changed a URI, a new location is searched for the new URI. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
40 This cycle may be repeated up to 10 times after which the error |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
41 <http-status code="500" text="Internal Server Error"/> is returned. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
42 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
43 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
44 </list> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
45 </para> |
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 </section> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
48 |
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 id="directives" name="Directives"> |
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 <directive name="break"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
53 <syntax/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
54 <default/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
55 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
56 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
57 <context>if</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
58 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
59 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
60 Stops processing the current set of |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
61 <literal>ngx_http_rewrite_module</literal> directives. |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
64 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
65 Example: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
66 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
67 if ($slow) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
68 limit_rate 10k; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
69 break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
70 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
71 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
72 </para> |
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 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
75 |
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 name="if"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
78 <syntax block="yes">(<value>condition</value>)</syntax> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
79 <default/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
80 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
81 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
82 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
83 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
84 The specified <value>condition</value> is evaluated. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
85 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
|
86 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
|
87 <literal>if</literal> directive. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
88 Configurations inside the <literal>if</literal> directives are |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
89 inherited from the previous configuration level. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
90 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
91 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
92 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
93 A condition may be any of the following: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
94 <list type="bullet"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
95 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
96 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
97 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
|
98 or any string starting with “<literal>0</literal>”; |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
101 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
102 comparing a variable with a string using the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
103 “<literal>=</literal>” and “<literal>!=</literal>” operators; |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
106 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
107 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
|
108 “<literal>~</literal>” (for case-sensitive matching) and |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
109 “<literal>~*</literal>” (for case-insensitive matching) operators. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
110 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
|
111 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
|
112 Negative operators “<literal>!~</literal>” and “<literal>!~*</literal>” |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
113 are also available. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
114 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
|
115 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
|
116 in single or double quotes. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
117 </listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
118 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
119 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
120 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
|
121 “<literal>!-f</literal>” operators; |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
124 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
125 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
|
126 “<literal>!-d</literal>” operators; |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
129 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
130 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
|
131 “<literal>-e</literal>” and “<literal>!-e</literal>” operators; |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
134 <listitem> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
135 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
|
136 and “<literal>!-x</literal>” operators. |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
139 </list> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
140 </para> |
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 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
143 Examples: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
144 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
145 if ($http_user_agent ~ MSIE) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
146 rewrite ^(.*)$ /msie/$1 break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
147 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
148 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
149 if ($http_cookie ~* "id=([^;]+)(?:;|$)") { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
150 set $id $1; |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
153 if ($request_method = POST) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
154 return 405; |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
157 if ($slow) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
158 limit_rate 10k; |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
161 if ($invalid_referer) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
162 return 403; |
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 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
165 <note> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
166 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
|
167 <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
|
168 </note> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
169 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
170 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
171 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
172 |
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 name="return"> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
175 <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
|
176 <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
|
177 <syntax><value>URL</value></syntax> |
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
178 <default/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
179 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
180 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
181 <context>if</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
182 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
183 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
184 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
|
185 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
|
186 a response header. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
187 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
188 |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
189 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 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
|
197 <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
|
198 <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
|
199 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
200 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
201 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
202 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
|
203 can be specified as the sole parameter. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
204 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
|
205 “<literal>https://</literal>”, or “<literal>$scheme</literal>”. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
206 A <value>URL</value> can contain variables. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
207 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
208 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
209 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
210 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
211 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
|
212 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
|
213 </note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
214 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
215 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
216 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
|
217 </note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
218 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
219 |
392
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
220 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
221 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
222 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
223 <directive name="rewrite"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
224 <syntax> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
225 <value>regex</value> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
226 <value>replacement</value> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
227 [<value>flag</value>]</syntax> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
228 <default/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
229 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
230 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
231 <context>if</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
232 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
233 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
234 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
|
235 as specified in the <value>replacement</value> string. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
236 The <literal>rewrite</literal> directives are executed sequentially |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
237 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
|
238 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
|
239 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
|
240 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
|
241 redirect is returned to a client. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
242 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
243 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
244 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
245 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
|
246 <list type="tag"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
247 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
248 <tag-name><literal>last</literal></tag-name> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
249 <tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
250 stops processing the current set of |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
251 <literal>ngx_http_rewrite_module</literal> directives |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
252 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
|
253 </tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
254 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
255 <tag-name><literal>break</literal></tag-name> |
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 stops processing the current set of |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
258 <literal>ngx_http_rewrite_module</literal> directives; |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
261 <tag-name><literal>redirect</literal></tag-name> |
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 returns a temporary redirect with the code 302; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
264 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
|
265 “<literal>http://</literal>” or “<literal>https://</literal>”; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
266 </tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
267 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
268 <tag-name><literal>permanent</literal></tag-name> |
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 returns a permanent redirect with the code 301. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
271 </tag-desc> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
272 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
273 </list> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
274 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
|
275 request scheme (<var>$scheme</var>) and the |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
402
diff
changeset
|
276 <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
|
277 <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
|
278 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
279 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
280 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
281 Example: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
282 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
283 server { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
284 ... |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
285 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
286 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
287 return 403; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
288 ... |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
289 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
290 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
291 </para> |
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 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
294 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
|
295 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
|
296 <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
|
297 return the error 500: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
298 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
299 location /download/ { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
300 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
301 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
302 return 403; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
303 } |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
304 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
305 </para> |
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 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
308 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
|
309 the previous request arguments are appended after them. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
310 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
|
311 string avoids having them appended, for example: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
312 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
313 rewrite ^/users/(.*)$ /show?user=$1? last; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
314 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
315 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
316 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
317 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
318 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
|
319 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
|
320 in single or double quotes. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
321 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
322 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
323 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
324 |
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 name="set"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
327 <syntax><value>variable</value> <value>value</value></syntax> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
328 <default/> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
329 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
330 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
331 <context>if</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
332 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
333 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
334 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
|
335 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
|
336 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
337 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
338 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
339 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
340 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
341 <directive name="uninitialized_variable_warn"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
342 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
343 <default>on</default> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
344 <context>http</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
345 <context>server</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
346 <context>location</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
347 <context>if</context> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
348 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
349 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
350 Controls whether warnings about uninitialized variables are logged. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
351 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
352 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
353 </directive> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
354 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
355 </section> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
356 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
357 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
358 <section id="internals" name="Internal Implementation"> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
359 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
360 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
361 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
|
362 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
|
363 that are interpreted during request processing. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
364 An interpreter is a simple virtual stack machine. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
365 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
366 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
367 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
368 For example, the directives |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
369 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
370 location /download/ { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
371 if ($forbidden) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
372 return 403; |
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 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
375 if ($slow) { |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
376 limit_rate 10k; |
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 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
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 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
382 will be translated into these instructions: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
383 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
384 variable $forbidden |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
385 check against zero |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
386 return 403 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
387 end of code |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
388 variable $slow |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
389 check against zero |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
390 match of regular expression |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
391 copy "/" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
392 copy $1 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
393 copy "/mp3/" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
394 copy $2 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
395 copy ".mp3" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
396 end of regular expression |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
397 end of code |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
398 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
399 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
400 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
401 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
402 Note that there are no instructions for the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
403 <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
|
404 directive above as it is unrelated to the |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
405 <literal>ngx_http_rewrite_module</literal> module. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
406 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
|
407 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
|
408 where <literal>limit_rate</literal> equals to 10k. |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
409 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
410 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
411 <para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
412 The directive |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
413 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
414 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
415 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
416 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
|
417 is put inside the parentheses: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
418 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
419 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
|
420 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
421 The corresponding instructions will then look like this: |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
422 <example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
423 match of regular expression |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
424 copy $1 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
425 copy "/mp3/" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
426 copy $2 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
427 copy ".mp3" |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
428 end of regular expression |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
429 end of code |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
430 </example> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
431 </para> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
432 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
433 </section> |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
434 |
5fd99d37a3e6
English translation of ngx_http_rewrite_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
435 </module> |