$is_args

The $is_args variable indicates whether the current request includes arguments in its query string. — NGINX Core (HTTP)

$is_args NGINX Core (HTTP)

Description

The $is_args variable in NGINX returns a string that is either empty or contains a single question mark ('?'). It specifically signifies the presence of query string parameters in the URI for the current request. When there are query parameters associated with a request (for example, '/path?arg=value'), the $is_args variable will evaluate to '?', which can be useful in constructing redirects or rewrites that preserve the query string in the target URI. The variable is set during the processing of a request within the NGINX request processing lifecycle. If the request URI does not include any query parameters, $is_args will be an empty string. On the contrary, if the request carries query parameters, such as 'arg1=value1&arg2=value2', NGINX will set $is_args to '?' only, regardless of the parameters present. Therefore, its value does not reflect the content of the query string itself but simply indicates its existence.

Config Example

location /example {
    if ($is_args) {
        rewrite ^ /another_example$is_args last;
    }
}

Subsystem

http

Cacheable

No

Contexts

http, server, location, if

Using $is_args in a context where it is not defined will lead to unexpected behavior. Ensure it is used in an appropriate context, typically inside a location or server block.

Avoid assuming that $is_args will provide the actual query string; it only provides a '?' if parameters exist, not their content.