title: How to do 301 redirect http to https in apache when website listening port 80 and 443?
body: <p>I am using apache2.4 &amp; configured website using drupal 7 . website is on port 80 &amp; ssl is enable on port 443 . 
  I have redirected homepage to https through websites admin login but on checking 301 redirection it says URLs are 
  being redirected using 302 Temporary Redirection instead of this 301 Permanent Redirection should be used as this is 
  considered SEO friendly redirection method. The only redirection i used so far is </p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^domain\.com [NC]
  RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301,NC] 
  </code></pre>
  
  <p>but its not redirecting from http to https . I even tried following rule</p>
  
  <pre><code>RewriteCond %{HTTPS} off [OR]
  RewriteCond %{HTTP_HOST} ^www.domain\.com*
  RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
  </code></pre>
  
  <p>can anyone help me how to redirect it permanently .</p>