The non www version of the website works but the www version of the website does not work. Flushing cache has not resolved the problem. I have added this lines to the .htaccess to switch the www version of the website to the non www version of the website but this does not work.
RewriteCond %{HTTP_HOST} ^www.examplecom [NC]
RewriteRule ^(.*)$ https:/examplecom/$1 [L,R=301,NC]
I am using the same domain name for hosting cyberpanel (on a google cloud vm instance with static ip) as being used for the website created within cyberpanel. The nameservers for the domain are pointed to google cloud and the dns records in google cloud dns have an A record and CNAME record set up correctly. The website created within cyberpanel also has dns records with the A record and CNAME record set up correctly to match dns records in google cloud dns.
The website loads fine without using www but continues not load when using www. Please advise how to resolve this problem.