flygoast / ngx_http_internal_redirect

A nginx module to make an internal redirect to the uri specified according to the condition specified.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NGINX HTTP Internal Redirect Module

Introduction

The ngx_http_internal_redirect_module is used to make an internal redirect to the uri specified according to the condition specified.

Synopsis

    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;
    }

Directives

  • 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.

Installation

    cd nginx-**version**
    ./configure --add-module=/path/to/this/directory
    make
    make install

Status

This module is tested with following nginx releases:

  • 1.2.6
  • 1.2.7
  • 1.23.1

Others are not tested.

Author

FengGu flygoast@126.com

About

A nginx module to make an internal redirect to the uri specified according to the condition specified.


Languages

Language:C 100.0%