title: AWS : Classic Load Balancer www.example.com not redirecting to https://www.example.com
body: <p>I have an EC2 instance on AWS which has route53 hosted zone.I have used AWS Certificate Manager for SSL and then used Classic Load balancer for the same to achieve https redirection.</p>
  
  <p>I have simple website running on that instance and have apache server installed with it. Also I have made .htaccess file for redirection.</p>
  
  <p>It works on following cases:</p>
  
  <pre><code>1] example.com -&gt; https://www.example.com
  2] https://www.example.com -&gt; https://www.example.com
  3] http://www.example.com -&gt; https://www.example.com
  </code></pre>
  
  <p>It should also work on the following case but it does not</p>
  
  <pre><code>www.example.com -&gt; https://www.example.com
  </code></pre>
  
  <p>I have written all the htaccess rule perfectly but when I add www redirection rule the load balancer status goes OutService.When I remove that rule it works perfectly.</p>
  
  <p>Working .htaccess for normal cases</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTP_HOST} ^example\.com [NC]
  RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
  </code></pre>
  
  <p>When I add rule for    www.example.com -> <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a></p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTPS} off [OR]
  RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
  RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
  </code></pre>