É necessário ter o módulo mod_rewrite habilitado.
RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.+) [NC] RewriteRule ^ http://%1%{REQUEST_URI} [R=302,L,NC]
RewriteEngine on RewriteCond %{HTTPS} off RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R=302,L,NC]