Recently I encountered an interesting issue with redirection from www to non-www. The non www site worked perfectly after migration to SSL, but the www site gave a 404 not found error, or a SSL server error.
The issue was solved in the end by the hosting company.
If a user has connected a site to Cloudflare using the service offered by many hosting providers within Cpanel then ONLY the domain at the root will be used.
If you have installed your site in a folder marked “mysite.com” then automatically connecting to Cloudflare means only http://mysite.com is actually running.
The www version will or “may” not work.
To convert your site to https you must first remove the site from Cloudflare and ensure that the name servers recommended by their hosting provider is being used.
Then do the conversion of the site and get everything set up correctly.
Finally they must manually re-add the site back into Cloudflare through the Cloudflare interface and NOT using the auto feature in Cpanel.
Once that is done and the name servers update the site will direct correctly to the www or non-www version as nominated in WordPress.