I believe this would work, but this code has not been tested. I think with SSL your Certificate is specific to the exact domain name. So it would be better to setup your site so that it is using the correct domain name in WordPress settings and anywhere else.
# https/SSL www to non-www # WP REWRITE LOOP START RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteCond %{SERVER_PORT} ^80 RewriteCond %{HTTP_HOST} ^www\.domainname\.com$ [NC] RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L] RewriteRule ^index\.php$ - [L] # https/SSL non-www to www # WP REWRITE LOOP START RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteCond %{SERVER_PORT} ^80 RewriteCond %{HTTP_HOST} ^domainname\.com$ [NC] RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R,L] RewriteRule ^index\.php$ - [L]