Mercurial > hg > nginx-site
changeset 1061:cb63563024eb
Somewhat clarified how rewrite module works.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Sat, 08 Feb 2014 16:23:06 +0400 |
parents | b841fbb8c577 |
children | 4002f7a0bf35 |
files | xml/en/docs/http/ngx_http_rewrite_module.xml xml/ru/docs/http/ngx_http_rewrite_module.xml |
diffstat | 2 files changed, 76 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/xml/en/docs/http/ngx_http_rewrite_module.xml Wed Feb 05 18:30:15 2014 +0400 +++ b/xml/en/docs/http/ngx_http_rewrite_module.xml Sat Feb 08 16:23:06 2014 +0400 @@ -10,13 +10,13 @@ <module name="Module ngx_http_rewrite_module" link="/en/docs/http/ngx_http_rewrite_module.html" lang="en" - rev="4"> + rev="5"> <section id="summary"> <para> The <literal>ngx_http_rewrite_module</literal> module is used to -change URIs using regular expressions, return redirects, and +change request URI using regular expressions, return redirects, and conditionally select configurations. </para> @@ -27,21 +27,32 @@ <listitem> the directives of this module specified on the -<link doc="ngx_http_core_module.xml" id="server"/> level are processed; -</listitem> - -<listitem> -a location for a request is searched; +<link doc="ngx_http_core_module.xml" id="server"/> level +are executed sequentially; </listitem> <listitem> -the directives of this module specified in the selected -<link doc="ngx_http_core_module.xml" id="location"/> are processed. -If they have been changing a URI, a new location is searched for the new URI. -This cycle may be repeated up to -<link doc="ngx_http_core_module.xml" id="internal">10 times</link> -after which the <http-status code="500" text="Internal Server Error"/> error -is returned. +repeatedly: +<list type="bullet"> + +<listitem> +a +<link doc="ngx_http_core_module.xml" id="location"/> +is searched based on a request URI; +</listitem> + +<listitem> +the directives of this module specified inside the found location +are executed sequentially; +</listitem> + +<listitem> +the loop is repeated if a request URI was <link id="rewrite">rewritten</link>, +but not more than +<link doc="ngx_http_core_module.xml" id="internal">10 times</link>. +</listitem> + +</list> </listitem> </list> @@ -65,6 +76,12 @@ </para> <para> +If a directive is specified inside the +<link doc="ngx_http_core_module.xml" id="location"/>, +further processing of the request continues in this location. +</para> + +<para> Example: <example> if ($slow) { @@ -224,6 +241,10 @@ </note> </para> +<para> +See also the <link doc="ngx_http_core_module.xml" id="error_page"/> directive. +</para> + </directive> @@ -238,7 +259,7 @@ <context>if</context> <para> -If the specified regular expression matches a URI, the URI is changed +If the specified regular expression matches a request URI, URI is changed as specified in the <value>replacement</value> string. The <literal>rewrite</literal> directives are executed sequentially in order of their appearance in the configuration file. @@ -262,7 +283,8 @@ <tag-name><literal>break</literal></tag-name> <tag-desc> stops processing the current set of -<literal>ngx_http_rewrite_module</literal> directives; +<literal>ngx_http_rewrite_module</literal> directives +as with the <link id="break"/> directive; </tag-desc> <tag-name><literal>redirect</literal></tag-name> @@ -349,7 +371,7 @@ <directive name="set"> -<syntax><value>variable</value> <value>value</value></syntax> +<syntax><value>$variable</value> <value>value</value></syntax> <default/> <context>server</context> <context>location</context>
--- a/xml/ru/docs/http/ngx_http_rewrite_module.xml Wed Feb 05 18:30:15 2014 +0400 +++ b/xml/ru/docs/http/ngx_http_rewrite_module.xml Sat Feb 08 16:23:06 2014 +0400 @@ -10,13 +10,13 @@ <module name="Модуль ngx_http_rewrite_module" link="/ru/docs/http/ngx_http_rewrite_module.html" lang="ru" - rev="4"> + rev="5"> <section id="summary"> <para> Модуль <literal>ngx_http_rewrite_module</literal> позволяет -изменять URI с помощью регулярных выражений, делать перенаправления +изменять URI запроса с помощью регулярных выражений, делать перенаправления и выбирать конфигурацию по условию. </para> @@ -26,22 +26,32 @@ <list type="bullet"> <listitem> -выполняются директивы этого модуля, описанные на уровне -<link doc="ngx_http_core_module.xml" id="server">сервера</link>; +последовательно выполняются директивы этого модуля, описанные на уровне +<link doc="ngx_http_core_module.xml" id="server"/>; </listitem> <listitem> -ищется location для запроса; +в цикле: +<list type="bullet"> + +<listitem> +ищется +<link doc="ngx_http_core_module.xml" id="location"/> +по URI запроса; </listitem> <listitem> -выполняются директивы этого модуля, описанные в выбранном -<link doc="ngx_http_core_module.xml" id="location"/>, -и если они изменяли URI, то ищется новый location для уже нового URI. -Этот цикл может повторяться до -<link doc="ngx_http_core_module.xml" id="internal">10 раз</link>, -после чего возвращается ошибка -<http-status code="500" text="Internal Server Error"/>. +последовательно выполняются директивы этого модуля, +описанные в найденном location; +</listitem> + +<listitem> +цикл повторяется, если URI запроса <link id="rewrite">изменялся</link>, +но не более +<link doc="ngx_http_core_module.xml" id="internal">10 раз</link>. +</listitem> + +</list> </listitem> </list> @@ -65,6 +75,12 @@ </para> <para> +Если директива указана внутри +<link doc="ngx_http_core_module.xml" id="location"/>, +дальнейшая обработка запроса продолжается в этом location. +</para> + +<para> Пример: <example> if ($slow) { @@ -223,6 +239,10 @@ </note> </para> +<para> +См. также директиву <link doc="ngx_http_core_module.xml" id="error_page"/>. +</para> + </directive> @@ -237,7 +257,7 @@ <context>if</context> <para> -Если указанное регулярное выражение соответствует URI, URI изменяется +Если указанное регулярное выражение соответствует URI запроса, URI изменяется в соответствии со строкой замены. Директивы <literal>rewrite</literal> выполняются последовательно, в порядке их следования в конфигурационном файле. @@ -261,7 +281,8 @@ <tag-name><literal>break</literal></tag-name> <tag-desc> завершает обработку текущего набора директив модуля -<literal>ngx_http_rewrite_module</literal>; +<literal>ngx_http_rewrite_module</literal> +аналогично директиве <link id="break"/>; </tag-desc> <tag-name><literal>redirect</literal></tag-name> @@ -347,7 +368,7 @@ <directive name="set"> -<syntax><value>переменная</value> <value>значение</value></syntax> +<syntax><value>$переменная</value> <value>значение</value></syntax> <default/> <context>server</context> <context>location</context> @@ -427,7 +448,7 @@ <link doc="ngx_http_core_module.xml" id="limit_rate"/> нет, поскольку она не имеет отношения к модулю <literal>ngx_http_rewrite_module</literal>. -Для блока <link id="if"/> создаётся отдельная конфигурация, +Для блока <link id="if"/> создаётся отдельная конфигурация. Если условие истинно, запрос получает эту конфигурацию, и в ней <literal>limit_rate</literal> равен 10k. </para>