'Redirect www non-https to non-www https on Cloudflare

I'm trying to get Cloudflare to route requests to:

http://www.example.com https://www.example.com http://example.com

to:

https://example.com

It seems to work pretty well out of the box with SSL enabled, etc. But I noticed that there's a redirect chain like this:

http://www.example.com -> 301 -> https://www.example.com -> 301 -> https://example.com

I would much rather just have the request to http://www.example.com redirect directly to https://example.com.

Does anyone know how to set this up? I have tried adding a rule to Cloudflare, but the redirect seems to be handled before running the rule. Or I misunderstood something.



Solution 1:[1]

For future visitors of this question, Cloudflare support solved this issue. The problem was that www wasn't orange-clouded in the DNS. After doing that, the page rule kicks in for all three URLs and redirects directly to the HTTPS, non-www variant.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ThomasArdal