Multiple www to non-www redirection in a single page rule

Hi I have recently added subdomains to support localization for my site and I’d like to use a single page rule to redirect all of them from www to non-www

I’m on a free plan so my page rules are limited

These are the DNS records I have atm. All the subdomains and www are CNAME to @,,,,,,,,,,* > 301 >$1
works great for the one of them

I was wondering if I can use something like

www.** > 301 > $$2

I hope that makes sense

Actually, a single page rule should be enough


However, I assume you do want to use SSL, right? In that case you’ll need the $10/month dedicated certificate from Cloudflare, otherwise all these www.XX hostnames won’t proxy.

1 Like

Thanks, @sandro

all the subdomains have valid certificate right now even on the free plan, that’s why I added them as a CNAME to @ instead of A record. I didn’t need to buy the certificate separately.

I tried this

www.** >$1

and got this redirect chain > > > 404 > > > 404

I referred to this document and made some adjustments.

www.** > https://$$2

You seem to use the language code as path instead.

You need to post a screenshot of your page rule.

No no, it’s working now. All good

www.** > https://$$2

:point_up_2: this worked perfectly

All right, that’s the rule I mentioned. Just asked because you pointed out 404s.

As for the certificate, it is a bit surprising that it works, as you should get an SSL error. But if it works, it works :wink:

1 Like

You are right. I don’t have a certificate for but I do have them for,
since www gets redirected, I think it’s all good :slight_smile:

That is my point, you need a certificate for that, otherwise the whole redirect is pointless as you will never reach it (unless you only want HTTP).

I checked it on

and it all looks good

Exactly, you sent the redirect on HTTP. Try it with HTTPS :wink:

Ah, I see. You are right.
It makes sense now.

So, if I install the letsencrypt certificates on my server for those www.XX hostnames, can I skip buying it from cf?

Only if you unproxy these www records.

I see, does the pro plan include advanced SSL?
If I’m gonna spend $10/mo, I might as well spend $20

The necessary certificate is independent of the plan. If you want HTTPS for these hostnames and you want it proxied you need the $10/month certificate.

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