HTTP directives
return directive (HTTP rewrite)
Rewrite module, server/location/if contexts; no default. Ends processing with the chosen response. Redirect forms supply a destination; a nonredirect status can carry text.
Formal Syntax & Structure
nginx syntaxnginx
return code [text];return code URL;return URL;Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| code | integer | HTTP response status for explicit-code forms. |
| text or URL | string | Response text or redirect destination depending on form. |
Working Example
Example Snippetnginx
location = /ping { return 200 "pong\n"; }