RewriteCond %{HTTP_HOST} ^site.ru
RewriteRule (.*) www.site.ru/$1 [R=301,L]
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} !^www\.(.*) [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTP} On
RewriteCond %{HTTP_HOST} ^site.ru
RewriteRule (.*) www.site.ru/$1 [R=301,L]