Nginx getting last variables on exploded uri

Where is the problem? I cound not found it.

My uri is :

/rdev/4/0/9/2/3/2/409232-750-0-257506-supra-ayakkabi-resimleri.jpg

Nginx conf is :

if ($request_uri ~* “/rdev/(.)-(.)-(.)-(.).jpg$”) {
set $exp1 $1;
set $exp2 $2;
set $exp3 $3;
set $exp4 $4;
}
add_header out_head1 $exp1;
add_header out_head2 $exp2;
add_header out_head3 $exp3;
add_header out_head4 $exp4;

Header Output :

out_head1: 4/0/9/2/3/2/409232-750-0-257506
out_head2: supra
out_head3: ayakkabi
out_head4: resimleri

I want to :

out_head1: 4/0/9/2/3/2/409232
out_head2: 750
out_head3: 0
out_head4: 257506-supra-ayakkabi-resimleri

Thanks.

Posted at Nginx Forum:

On Mar 15, 2014, at 21:30 , gokhanege wrote:

set $exp2 $2;

out_head1: 4/0/9/2/3/2/409232-750-0-257506

Thanks.

location ~
^/rdev/(?[^-]+)-(?[^-]+)-(?[^-]+)-(?.+).jpg$ {

}

On 15 Mar 2014 17:30, “gokhanege” [email protected] wrote:

Where is the problem? I cound not found it.

Your problem is that all of your .* matches are greedy, whereas you
(probably) want only the last to be greedy. Have a Google for how to do
that with regular expressions.

You also might want to replace /some/ of your “(.)" with "([^-])” if
they
should /never/ contain hyphens.

HTH,
J

Thanks for all. Working it now.

Posted at Nginx Forum: