RewriteCond %{HTTPS} off [OR]RewriteCond %{HTTP_HOST} ^www\. [NC]RewriteRule ^(.*) https://yourdomain.com%{REQUEST_URI} [R=301,L,NE]