RewriteEngine On RewriteCond %{REQUEST_URI} !=/robots.txt [NC] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule .* https://%1%{REQUEST_URI} [R=301,L] RewriteCond %{REQUEST_URI} !=/robots.txt [NC] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{REQUEST_URI} !=/robots.txt [NC] RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]