Hi, and welcome!
If your forum is located at https://www.mydomain.com, then you actually want to redirect https://mydomain.com to https://www.mydomain.com (not the other way around). To do this:
- Visit the Cloudflare dashboard and select your domain.
- Click on the ‘Page Rules’ tab.
- Click on ‘Create Page Rule’.
- In the ‘If the URL matches’ field, input
mydomain.com/*
.
- Select ‘Forwarding URL’ under ‘Then the settings are’, and choose a 301 (Permanent Redirect) status.
- In the ‘Enter destination URL’ field, input https://www.yourdomain.com/$1.
- Click ‘Save and Deploy’ to create the rule.
Ref.: https://community.cloudflare.com/t/558655 (except I did it the other way around, non-WWW
<-> WWW
).
Note that page rules (and all Cloudflare-related features, after all) will only work if your domain is proxied through Cloudflare (I think that you can turn on the proxy after you have successfully CNAMEd your forum)