http or http www to https www with only one redirection
<p>in .htacces I am trying to redirect to <a href="https://www">https://www</a></p>

<p>this is working fine</p>

<pre><code>RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</code></pre>

<p>but with 2 redirections I'd like to do it with only 1 redirection</p>

<p>I have tried</p>

<pre><code>RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</code></pre>

<p>it works fine but if the s is removed (step 2) I get 2 times www
1) <a href="https://www.domain.com" rel="nofollow">https://www.domain.com</a> --> 2) <a href="http://www.domain.com" rel="nofollow">http://www.domain.com</a> --> 3) <a href="https://www.www.domain.com" rel="nofollow">https://www.www.domain.com</a></p>

<p>how can I redirect ?</p>

<pre><code> http://domain.com
 http://www.domain.com
 https://domain.com
to
 https://www.domain.com
</code></pre>

<p>with only one redirection  and no error whatever happen</p>

<p>thanks for helping</p>