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"
According to NGINX documentation, $request_uri is the original request (for example, /foo/bar. php? arg=baz includes arguments and can't be modified) but $uri refers to the altered URI.
The try_files directive commonly uses the $uri variable, which represents the part of the URL after the domain name. In the following example, NGINX serves a default GIF file if the file requested by the client doesn't exist.
REQUEST_URI is the path component of the URI in the request. For example, /tq_info. php . REQUEST_FILENAME is the result of trying to find the file in the local filesystem by applying the URI path to the document root or any alias that might have been defined.
I use this map, which works without lua:
map $request_uri $request_uri_path {
"~^(?P<path>[^?]*)(\?.*)?$" $path;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With