Use the following .htaccess code to redirect non-www URLs to www over http and https.
Create, or edit if already exists, .htaccess file in the root directory (web / httpdocs / www) of web hosting account and add in the code below:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]