Welcome! Log In Create A New Profile

Advanced

Fetching a string by parsing URL

July 22, 2015 12:43AM
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.
Subject Author Posted

Fetching a string by parsing URL

sudharshanr July 22, 2015 12:43AM

Re: Fetching a string by parsing URL

Edho Arief July 22, 2015 12:56AM

Re: Fetching a string by parsing URL

sudharshanr July 22, 2015 02:17AM

Re: Fetching a string by parsing URL

unclepieman July 22, 2015 08:22AM

Re: Fetching a string by parsing URL

sudharshanr July 22, 2015 01:08PM

Re: Fetching a string by parsing URL

Edho Arief July 22, 2015 02:14PM

Re: Fetching a string by parsing URL

sudharshanr July 22, 2015 07:31PM

Re: Fetching a string by parsing URL

sudharshanr July 23, 2015 02:36PM

Re: Fetching a string by parsing URL

sudharshanr July 23, 2015 03:32PM

Re: Fetching a string by parsing URL

Francis Daly July 24, 2015 06:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 202
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready