The ngx_http_internal_redirect_module
is used to make an internal redirect to the uri specified according to the condition specified.
location / {
internal_redirect_if ($request_method = 'FOO') skip;
internal_redirect_if ($request_method = 'FOO') @foo;
internal_redirect_if ($request_method = 'BAR') /foo;
internal_redirect_if ($request_method = 'BAZ') =200;
internal_redirect_if ($request_method = 'QUZ') "$foo$bar";
root html;
}
location @foo {
return 200;
}
location /bar {
return 200;
}
- syntax: internal_redirect_if (condition) skip
- syntax: internal_redirect_if (condition) uri
- syntax: internal_redirect_if (condition) =code
- default: --
- context: http, server, location
The specified condition
is evaluated. If true, an internal redirect would be made to the uri
specified in this directive. The syntax of condition is the same as it in the if
directive in rewrite
module. The syntax of uri
is the same as it in the try_files
directive. If the last argument is skip
, this handler would be skipped.
- syntax: internal_redirect_if_no_postponed on | off
- default: off
- context: http
Control whether or not to disable postpone the internal_redirect_if
directives to run at the end of the request-processing phase. By default, this directive is turned off.
- syntax: internal_redirect_if_phase post_read | rewrite
- default: rewrite
- context: http
The phase to which this handler would register to. Note, if set to post_read
, the conditions set in location {}
would not come to force.
cd nginx-**version**
./configure --add-module=/path/to/this/directory
make
make install
This module is tested with following nginx releases:
- 1.2.6
- 1.2.7
- 1.23.1
Others are not tested.
FengGu [email protected]