Redirect non-www to www Google Sites?

Redirect non-www to www Google Sites?
i have cname record so that www shows google sites
But cant make https non-www and http non-www to redirect to https www

1 Like

What’s not working? What are you using for your redirects? Page Rules, Transform Rules, Workers?

2 Likes

Google sites need only one thing- cname
CNAME www ghs.googlehosted .com
but how to make nonwww to www redirect?
I made redirect Redirect Rules but it didnt work latvijai .lv/* to www. latvijai . lv/$1 , also i had http:// wwwizer. com/ but it didnt work with https only http so i removed and now have www. latvijai.lv redirected you too many times. ERR_TOO_MANY_REDIRECTS
And redirect i removed and still with www. latvijai . lv dont work now

1 Like
  1. Under CNAME value or alias, enter www
  2. In CNAME destination, enter ghs.googlehosted. com. (include period at the end)
  3. Save changes
  4. Come back to this tab and click Done
1 Like

Google sites need only one thing- cname
CNAME www ghs.googlehosted .com
but how to make nonwww to www redirect?
I made redirect Redirect Rules but it didnt work domain .lv/* to www. domain . lv/$1 , also i had http:// wwwizer. com/ but it didnt work with https only http so i removed and now have www. domain.lv redirected you too many times. ERR_TOO_MANY_REDIRECTS
And redirect i removed and still with www. domain . lv dont work now

  1. Under CNAME value or alias, enter www
  2. In CN AME destination, enter ghs . googlehosted. com. (include period at the end)
  3. Save changes
  4. Come back to this tab and click Done

Without www shows DNS_PROBE_FINISHED_NXDOMAIN
Here are current settings

You have two different issues:

DNS_PROBE_FINISHED_NXDOMAIN occurs because you don’t have a record for your apex (domain.lv in your example). You need to create a DNS Record for Cloudflare’s DNS to respond with Cloudflare’s Proxy IPs and get traffic flowing through Cloudflare. Cloudflare recommends you use either an A Record with the IPv4 reserved address of 192.0.2.0, or an AAAA record with the IPV6 Discard Address of 100::, for originless setups. Your redirect rule will handle the request before it tries to talk to your origin.

You can fix that by creating a record on your apex just like this:

Your second problem is that you seem to be trying to follow a guide for using a page rule to redirect from apex (domain.lv) to your www subdomain, but you are trying to do it within a dynamic redirect. Dynamic Redirects do not support that style of wildcards/replacements.
You could make that rule, as a page rule, with the same source (domain.lv/*), and with a target of https://www.domain.lv/$1, and it should work.
Alternatively, you could use bulk redirects. There is a guide here on how you could redirect from www to apex. You would just have to do it backwards basically.

You would create the DNS Record for your apex (@), if you haven’t already.

Then the source url would be example.lv, and the target url https://www.example.lv, with the same parameters.
Redirecting www to domain apex · Cloudflare Pages docs

1 Like

Ok i made a 192.0.2.1 and aaa 100:: for @ without www
in Redirect example.com to www.example.com
is mentioned 192.0.2.1

i have Rules - Redirect rules in pic in not dynamic but static with /* and www/$1

Where is bulk redirects?

In guide is Bulk redirects, but they dont exist in my panel
image

oh found it. its deeper in Redirect rules scrolling lower

How to use 1st one without bulk redirects? What is better?

Hi,

Bulk Redirects, Redirect Rules, Transform Rules, it’s all a bit confusing at first. I believe your use-case asks for a single dynamic Redirect Rule.

Since you’re using the Hostname field, the “value” cannot have / or *. Also, as @Chaika noted, you should not use Page Rules wildcards when using Redirect Rules. You can you the fields, then you’d need to reassemble the URL using the concat() function. I haven’t tested, but you can try this:

If hostname is:

example.com

Redirect to:

concat("https://www.example.com", http.request.uri.path)

with Preserve Query String enabled.

Check the Redirect Rules documentation for more details:

So then its not simple solution choosing from option dropdown?

One post before Bullk i tried and it gives ERR_CONNECTION_TIMED_OUT
Now disabling BUlk
Oh so i had single before but it was (http.host eq “domain.lv/*”) and i turned it off when using Bulk, like this

So then i edit expression and change Static to Dynamic and Preserve Query string.

This single redirect would never work for the reason @Chaika has mentioned already. Wildcard * and placeholders $1 etc. do not work with Redirect Rules. They only work with Page Rules. Page Rules are being replaced with 4 different products, among them Redirect Rules. So at this point and time it’s best not to use Page Rules if you can avoid them.

Yes. Static would be used if all URLS with the hostname were to be redirected to a single URL (the homepage, for instance).

Error
‘concat(“http s://domain .lv”, http.request.uri.path)’ is not a valid value for expression because the expression is invalid: Filter parsing error (1:53): concat(“http s://domain .lv”, http.request.uri.path) ^ expected ComparisonOp

Error
‘concat(“http s://domain .lv”, http.request.uri.path)’ is not a valid value for expression because the expression is invalid: Filter parsing error (1:53): concat(“http s://domain .lv”, http.request.uri.path) ^ expected ComparisonOp

You’re using concat() in the wrong place. Try to follow this:

ERR_CONNECTION_TIMED_OUT
i get