문제

I have this url:

http://127.0.0.1:8085/test2/Y2hpc3Rh?sx=MTU5OQ==&sy=MTk4&sz=MTg=

and i want to rewrite it to:

/tms/$1/$2/$3/$4.png;

I have this regex:

rewrite /[\w]+/([\w\d]*)?[\w]+[\w]+=([\w\d=]*) /tms/$1/$2.png;

it should work like: /tms/Y2hpc3Rh/MTU5OQ.png but it doesn't. Nginx can not find the groups. What is the problem here?

도움이 되었습니까?

해결책

Try this:

rewrite ^/\w+/(\w*)/?$ /tms/$1/$arg_sx/$arg_sy/$arg_sz.png;

Nginx doesn't include the query-string in the match for rewrite. You can access the parameters by name via $arg_name.

\w is equivalent to [A-Za-z0-9_], so it includes digits.

다른 팁

untested

http://[^/]+/[^/]+/([^?]+)[^=]+=([^=]+)=.* 

/tms/$1/$2.png
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top