Need help with redirecting urls

What is the name of the domain?

nestment.com

What is the issue you’re encountering

Hi there, New to cloudflare. I am trying to create a redirect rule where for example a specific url link https://suba.example.com?property=1234A would go to https://subc.example.com/property/1234A but I am unsuccessful. can anyone help me with a step by step process

What have you done so far?

Is the subdomain you’re redirecting from proxied?

And can you share details of a screenshot of your redirect rule?

2 Likes

Hi, thank you for responding quickly

Here is my process. what I am trying to do is get the property={value} and store it where there is $1 on a Redirect Rule

To make this work, you need to:

  1. Change type from Static to Dynamic (Static is for literal URL targets)
  2. Use a function to perform wildcard expansion in the redirect target URL: Functions reference · Cloudflare Ruleset Engine docs
  3. If you want to match on any property value, then you need to change contains operator to wildcard; otherwise, contains will interpret * literally

This process will become much easier and more intuitive once simplified URL with wildcard support is released for Single Redirects in the upcoming days. :wink:

1 Like

Thank you for the help. I am not sure how to use Dynamic expressions on the input

https://subc.domain.com/list/example/${query.property}?group=${query.group}
is giving me an espression error. do you have an example?

The syntax for wildcard expansion is ${x} where x indicates the index of a matched pattern.

Try this:

  1. Filter expression: (http.request.full_uri wildcard "https://suba.domain.com/thisredirects?*property=*")
  2. Action type: Dynamic
  3. Action expression: wildcard_replace(http.request.full_uri, "https://suba.domain.com/thisredirects?*property=*", "https://subc.domain.com/shared/place/${2}")

It should look like this in the UI:

If you’re trying to capture and expand multiple variables, your filter expression could be something like (http.request.full_uri wildcard "https://suba.domain.com/thisredirects?*property=*group=*").

Your action expression can then reference captured groups in the order they appear in the filter: wildcard_replace(http.request.full_uri, "https://suba.domain.com/thisredirects?*property=*group=*", "https://subc.domain.com/list/example/${2}?group=${3}")

2 Likes

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

You can now use the simple UI to configure redirects like this: Go wild: Wildcard support in Rules and a new open-source wildcard crate.

1 Like