Fetching a string by parsing URL

sudharshanr nginx-forum at nginx.us
Wed Jul 22 04:43:09 UTC 2015


I have a web server sitting behind Nginx. If there is an error, then I want
to fetch some information from the url and pass it on to a static file as
parameters. I have configured Nginx to fetch the query parameters from the
url using $arg_param_name. 

However, I also need to fetch a String from the url path itself. For
instance, if the url is "www.website.com/path1/path2?arg1=val&arg2=someval",
how can I parse this url to fetch the last path (path2 in this case)? My
location directive is as below:

location ~*/path1/{
   ...
}

The url, however, need not always have the same number of paths. It can also
have 3 paths. So I can't use $1, $2 etc. I need to fetch the last path, i.e
the path which is immediately followed by the query parameters (the ?
symbol). Is it possible to do this using Nginx directly?

Thanks.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,260458,260458#msg-260458



More information about the nginx mailing list