Rules for redirect from non www to www

I need to redirecto from root to www.
I don’t have IP for root, because I use a SaaS producto and they provide the CNAME info for www, and I created a CNAME for root. Cloudflare support it with “CNAME flattening”.

Now, I created 2 roles that doesn’t work. According the documentation.

1: HTTP to HTTPS
when “(starts_with(http.request.full_uri, “http://”))”, dynamic redirecto to the url with www, with status code 301

2: Root to WWW
when “(http.host eq “mysite . com”)”, dynamic redirect to “concat(“https://www.mysite . com”, http.request.uri . path)”, with status code 301

but none of them work.

Note: There are a few “.com” with spaces, because I can’t create topics with more than 4 links

HTTP to HTTPS is best done by enabling “Always use HTTPS” in Cloudflare.

For the redirect…

Create a redirect rule here…
https://dash.cloudflare.com/?to=/:account/:zone/rules/redirect-rules

Copy this example exactly, just changing the hostnames…

Then you need to create a DNS record for the domain you are redirecting from in your Cloudflare dashboard…
https://dash.cloudflare.com/?to=/:account/:zone/dns/records

Add a proxied dummy value of A 192.0.2.1 or AAAA 100:: for @ as the domain is being redirected and there’s no real origin server.

Ok
I did all of these configuration, “Always Use HTTPS” and the rule. But none of this works.
I’m not sure what is wrong.

The record

The A record of 192.0.2.1 must be Proxied, you have it as “DNS only”.

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