Page redirect from root to www not working

I have a GCP static website set up with Cloudflare to use my www subdomain modeled after www.example.com. Because I want the root url e.g. example.com also to land on the same place, I added a page rule that should redirect from the equivalent of example.com to www.example.com but it doesn’t work. I tried various versions such as:

example.com/*

Forwarding URL 301 Permanent redirect

https://www.example.com/$1

with “example” replaced with my domain name. But the url would always give me a DNS_PROBE_FINISHED_NXDOMAIN error. In the end I created a second GCP storage bucket that points at my naked domain and added a 404.page on this site that has a client side redirect that points to the www url. But using a client side redirect is less efficient than a server redirect. Why doesn’t the page rule work? How can I debug this?

You simply needs to have a DNS record for yourdomain.com that is proxied :orange:. It can be point to anywhere.

It seems when using GCP, the www subdomain and root domain need to have separate storage buckets because in both cases the CNAME entries looks like

www c.storage.googleapis.com
@ c.storage.googleapis.com

Before I added the second bucket, I thought I could rely on a page rule to redirect traffic from the root to www but it didn’t seem to work. Still don’t understand why not.

I got mine Google Cloud Storage setup with :orange: proxied mode enabled as a CNAME static. Working like a charm.

Nevertheless, created a Page Rule for that sub-domain with the Cache Level: Cache Everything and Edge Cache TTL.

Not possible with Cloudflare SSL:

Neither GCS has got the SSL certificate / not working over HTTPS as far as I know (at least it was like that two-three years ago since I have used it like that)

If so, you would have to create a Page Rule to redirect it (your naked/root domain non-www to www - while all the behind it loads the resources from storage.googleapis.com).

1 Like

I already explained what you need to do in my previous reply. @fritex also gave you a clear example.

In short, page rules won’t work if you don’t have a proper DNS record (which must be proxied :orange:) for that particular subdomain.

1 Like

googleapis.com owns by Google. So it shouldn’t be related to Cloudflare.

1 Like

Nope, I still think the HTTPS doesn’t work on GCS even nowadays as far as:

… Since Cloud Storage doesn’t support custom domains with HTTPS on its own, this tutorial uses …
… You can also use Cloud Storage to serve custom domain content over HTTP, which doesn’t require a load balancer. …

Source:

HTTPS serving

Issue : I want to serve my content over HTTPS without using a load balancer.

Solution : You can serve static content through HTTPS using direct URIs such as https://storage.googleapis.com/my-bucket/my-object . For other options to serve your content through a custom domain over SSL, you can:

Source:

If correct, those solutions don’t support HTTPS by default. Google Cloud Platform does offer a guide for setting up a site with GCS with an HTTPS load balancer in front of it, but the load balancer costs a bit per month.

  • or I am still using the old resource of information since when I used it? - could be I am wrong about it nowadays …

Meaning, the Flexible SSL is the only way to work - which we really do not want to use as it will be un-encrypted way:

Or it actually could work by using Full SSL option (not the Strict one) - as it fails back to HTTP (not HTTPS)?

I should again try that out first to have the correct information for further cases :wink:

Last but not least, we should always aim to the correct SSL settings (Full (Strict) SSL)as written on the below article:

Ok so that’s what I’ve done by adding a second GCP bucket that is pointed to by adding:

CNAME @ c.storage.googleapis.com

So with that in place, should the page rule redirect now work? If this worked then the second bucket is never actually visited even though I needed it in order to get this entry to work. What do you mean by @fritex’s clear example btw? What does the word “static” do in the subdomain? What is wrong the CNAME entries I put?

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