0

I am trying to write a url rewrite for the following case. I have a proxy server which has sub routes and each route is mapped to a backend. I need a regex for the following case

/proxy/vms/some/cool/route ==> /some/cool/route
/proxy/oms/another/route ===> /another/route
/proxy/ims/another/route?query ===> /another/route?query
/proxy/some-word-with-character/fourth/route ===> /fourth/route

Basically the /proxy part and the immediate child is stripped off from the url. The immediate child can have special characters

I tried the following regex

'^/proxy(/.*)$': '$1'

But im getting incorrect groups in this . Any help would be useful

1 Answer 1

1

You can take the part after the second / and then match 1 or more non whitespace characters.

Then use that group 1 value.

^/proxy/[^/]*(/\S+)

Regex demo

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

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.