http-internal-redirect #

ngx_http_internal_redirect_module allows making an internal redirect. In contrast to rewriting URIs, the redirection is made after rewrite phase. Currently supported request phases are preaccess, access, precontent and content, allowing it to be used with many nginx official or third-party modules.

Source: upstream source

Directives

internal_redirect #

syntax: internal_redirect [-i] pattern replacement [phase=<phase>] [flag=<flag>] [if=<condition> | if!=<condition>]  ·  default: -  ·  context: http, server, location

The optional -i parameter specifies that a case-insensitive regular expression match should be performed. The optional flag= parameter is used for additional actions after evaluating the rule. The value of this parameter can be one of: stops processing the current set of rules at this phase, and immediately executes an internal redirection;

Example

server {
    listen 127.0.0.1:80;
    server_name localhost;

    location /old {
        internal_redirect -i ^/old(.+) /new$1 phase=preaccess;
    }

    location /new {
        return 200 'current uri is: $uri';
    }
}

↑ back to index