How do I get the value of request_uri
without the args appended on the end. I know there is a uri
variable but I need the original value as the Nginx documentation states:
request_uri
This variable is equal to the original request URI as received from
the client including the args. It cannot be modified. Look at $uri for
the post-rewrite/altered URI. Does not include host name. Example:
"/foo/bar.php?arg=baz"
You're looking for $uri. It does not have $args. In fact, $request_uri is almost equivalent to $uri$args.
If you really want exactly $request_uri with the args stripped, you can do this.
local uri = string.gsub(ngx.var.request_uri, "?.*", "")
You will need to have lua available but that will do exactly what you're asking.
I use this map, which works without lua:
map $request_uri $request_uri_path {
"~^(?P<path>[^?]*)(\?.*)?$" $path;
}