Put the following lines in your .htaccess file and replace mydomain.com with the domain you want to redirect.
RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.){0,1}mydomain.com$ [OR] RewriteCond %{HTTPS_HOST} ^(www\.){0,1}mydomain.com$ RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]
To do this, you will have to delete the existing entries that you mentioned in your question from the .htaccess file
source share