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

NameTypeDescription
codeintegerHTTP response status for explicit-code forms.
text or URLstringResponse text or redirect destination depending on form.

Working Example

Example Snippetnginx
location = /ping { return 200 "pong\n"; }
Nginx Reference