Hello there,
I'm trying to set a new variable based on another one.
I've found this response which is kinda close to what i want to do : https://www.ruby-forum.com/topic/6876231#1176774
map $request_uri $last_path {
~/(?<pathname>[^/]+)/?$ $pathname;
}
Except, i want to get the first path level only (and not the file name) !
It seems to work fine even if the syntax seems not really correct, here is what i came up with (and it's working) :
map $request_uri $last_path {
~/(?P<pathname>[^\/]+)/?$ $pathname;
}
But, as soon as i try to make changes in order to get the first path, my $last_path value is empty...
I guess i didn't succed in making all the changes required for it to work...
Here is some of my attemps (please don't laugh), not working :
~/^\/(?P<pathname>[^\/]+)/? $pathname;
~/^\/(?P<pathname>)[^\/]+/? $pathname;
~/^[\/+](?P<pathname>[^\/]+)/? $pathname;
~/^[\/+](?P<pathname>)[^\/]+/? $pathname;
To be clear on what i expect :
/a for /a/b/c.png
/a for /a/c.png
/ for /c.php
Thanks in advance !