1

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?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

untested

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

/tms/$1/$2.png

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.