Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx request_uri without args

Tags:

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"

like image 343
Kyle Decot Avatar asked Jan 31 '12 18:01

Kyle Decot


People also ask

What is nginx $Request_uri?

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.

What does URI mean in nginx?

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.

What is $Request_uri?

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.


1 Answers

I use this map, which works without lua:

map $request_uri $request_uri_path {
  "~^(?P<path>[^?]*)(\?.*)?$"  $path;
}
like image 82
Ryan Olson Avatar answered Sep 19 '22 18:09

Ryan Olson