# Proxy Rewrite Configuration

The `proxy-rewrite` plugin offers flexible options to rewrite requests that API gateway forwards to upstream services, enhancing API management.<!-- --> <!-- -->Configuration covers plugin parameters.

## Parameters[​](#parameters "Direct link to Parameters")

See plugin [common configurations](https://docs.api7.ai/apisix/reference/plugin-common-configurations.md) for configuration options available to all plugins.

* uri

  string

  ***

  New upstream URI path. Value could be a [built-in variable](https://docs.api7.ai/apisix/reference/built-in-variables.md).

* method

  string

  valid value:

  `GET`, `POST`, `PUT`, `HEAD`, `DELETE`, `OPTIONS`, `MKCOL`, `COPY`, `MOVE`, `PROPFIND`, `LOCK`, `UNLOCK`, `PATCH`, or `TRACE`

  ***

  HTTP method to rewrite requests to use.

* regex\_uri

  array\[string]

  ***

  Regular expressions used to match the URI path from client requests and compose a new upstream URI path. When both `uri` and `regex_uri` are configured, `uri` has a higher priority.

  Provide one or more pairs in a flat array. Odd-positioned elements are the match pattern and even-positioned elements are the replacement. The plugin evaluates pairs in order and applies the first match.

  For example, with `["^/test/(.*)/(.*)", "/$1-$2", "^/other/(.*)", "/other"]`, a request to `/test/user/agent` is rewritten to `/user-agent`, and a request to `/other/hello` is rewritten to `/other`.

* set\_ngx\_uri

  boolean

  default: `false`

  ***

  Available in API7 Gateway 3.9.21 and 3.10.8. This field is not available in APISIX 3.19.0, which updates `ngx.var.uri` to the rewritten upstream URI when `use_real_request_uri_unsafe` is false.

  In API7 Gateway, when `use_real_request_uri_unsafe` is false, `ngx.var.uri` remains the original normalized request URI if `set_ngx_uri` is false and is updated to the rewritten upstream URI if `set_ngx_uri` is true. When `use_real_request_uri_unsafe` is true, neither product updates `ngx.var.uri`.

* host

  string

  ***

  Set [`Host`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host) request header.

* headers

  object

  ***

  Header actions to be executed. Can be set to objects of action verbs `add`, `remove`, and/or `set`; or an object consisting of headers to be `set`.

  When multiple action verbs are configured, actions are executed in the order of `add`, `set`, and `remove`. For the same header, `set` overwrites values from `add`, and `remove` deletes the header after both operations.

  * add

    object

    ***

    Headers to append to requests. If a header is already present in the request, the header value will be appended. Header value could be set to a constant, one or more [built-in variables](https://docs.api7.ai/apisix/reference/built-in-variables.md), or the matched result of `regex_uri` using variables such as `$1-$2-$3`.

    A header value can also be an array. Each value is resolved independently and appended as a separate header line in array order. Introduced in API7 Enterprise 3.9.17 and 3.10.4, and APISIX 3.18.0.

  * set

    object

    ***

    Headers to set to requests. If a header is already present in the request, the header value will be overwritten. Header value could be set to a constant, one or more [built-in variables](https://docs.api7.ai/apisix/reference/built-in-variables.md), or the matched result of `regex_uri` using variables such as `$1-$2-$3`.

    A header value can also be an array. Each value is resolved independently, and the array replaces any existing value with separate header lines in array order. Introduced in API7 Enterprise 3.9.17 and 3.10.4, and APISIX 3.18.0.

    Should not be used to set `Host`.

  * remove

    array\[string]

    ***

    Headers to remove from requests.

* use\_real\_request\_uri\_unsafe

  boolean

  default: `false`

  ***

  If true, bypass URI normalization and allow for the full original request URI. Enabling this option is considered unsafe.
