Transform Rule with Regex not working

What is the name of the domain?

www.vicbar.com.au

What is the error number?

No error number

What is the error message?

No error message

What is the issue you’re encountering

I need a complex URL rewrite to take place for a customer and i’ve built a transform rule to accomplish this. The regex syntax i’m using is correct as far as i’m aware but it’s not working the way i want it to.

What steps have you taken to resolve the issue?

I’ve used the Trace tool to ensure that my rule is being hit, it is. I’ve used regex101.com to test my syntax and i can’t find any errors there so i’m not sure why it’s not working.

I need the following URL https://www.vicbar.com.au/profile/25508 re-written to the following: https://www.vicbar.com.au/web/profile?ID=25508 and this is what I’m using in the rule for the Path variable to be rewritten to:

regex_replace(http.request.uri.path, “^/profile/([^/])+$”, “/web/profile?ID=${1}”)

You need to split across the Path and the Query string, and fix the match for the characters at the end by using this RegEx: regex_replace(http.request.uri.path, "^/profile/(.+)$","ID=${1}")

Your rule should look like this:

1 Like

Thank you! That helped make it work but it also made me realize, that I’m somewhat (that’s being kind) of an idiot because rewrite <> redirect and while the page now ‘works’ in that it doesn’t error out or 404…it doesn’t fully pull the necessary underlying data and therefore I’m going to need to use a redirect instead.

Thanks again for your quick and correct answer, it is appreciated!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.