Redirect example.com/* to www.example.com/$1

What is the name of the domain?

lamusiquedegenevieve.com

What is the error number?

none given

What is the error message?

none given

What is the issue you’re encountering

Cant make the redirection work

What steps have you taken to resolve the issue?

I created a rule (see screenshot). I must redirect everything to www because Google site creation tool only support custom domains with www. My redirection does not work. I also added dummy 192.0.2.1 for A DNS record.

What are the steps to reproduce the issue?

see screenshot

Screenshot of the error

Greetings,

Thank you for asking.

Kindly, do as follows from the screenshot below.

From the above screenshot, everything which is under non-www version lamusiquedegenevieve.com will redirect (301) to the www-version www.lamusiquedegenevieve.com, including the sub-path(s) and queries like ?abc=def.

Make sure A www points to the correct IP and is proxied :orange: , therefore the A lamusiquedegenevieve.com (or @) points to the temporary IP address like 192.0.2.1 and is also proxied :orange: to make sure it’ll be applied as needed under the DNS tab of Cloudflare dashboard.

Helpful article:

1 Like

You can use concat function mentioned above, or you can fix your wildcard rule. The problem is in the target of the redirect. Static URL redirect target is interpreted as a string, so variable is not going to be expanded there.

What you need to do is:

  1. Change type from Static to Dynamic (this is required for concat method too, by the way)
  2. Change https://www.lamusiquedegenevieve.com/$1 to wildcard_replace(http.request.full_uri, "https://lamusiquedegenevieve.com/*", "https://www.lamusiquedegenevieve.com/${1}") in the URL redirect URL target

Note that the syntax for wildcard expansion is ${X}, where <X> indicates the index of a matched pattern. You can read more about it in wildcard replacement.

As I mentioned here, 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 very much! It worked well after proxying the A record with Cloudflare and adjusting the expression.

1 Like

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