title: .htaccess force www. and https for specific domain
body: <p>I have a server which is accessed by several domains. 
  All of those domains MUST have www. in front.</p>
  
  <p>Only 1 domain should be HTTPS, the other's HTTP since I only had an SSL certificate for on domain.</p>
  
  <p>I tried the following code in my .htaccess file</p>
  
  <p>RewriteEngine On</p>
  
  <pre><code># First force domain to use www.
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  # Then force https
  RewriteCond %{HTTPS} off
  RewriteCond %{HTTP_HOST} ^amanvida.eu [NC,OR]
  RewriteCond %{HTTP_HOST} ^www.amanvida.eu [NC]
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
  </code></pre>
  
  <p>The domain that should force https is www.amanvida.eu</p>
  
  <p>However it is not working fully as expected
  <a href="https://www.amanvida.eu/nl/amanprana-serum-gezicht-shangri-la.html" rel="nofollow">https://www.amanvida.eu/nl/amanprana-serum-gezicht-shangri-la.html</a>
  - works, of course</p>
  
  <p><a href="http://www.amanvida.eu/nl/amanprana-serum-gezicht-shangri-la.html" rel="nofollow">http://www.amanvida.eu/nl/amanprana-serum-gezicht-shangri-la.html</a> - works</p>
  
  <p><a href="http://amanvida.eu/nl/amanprana-serum-gezicht-shangri-la.html" rel="nofollow">http://amanvida.eu/nl/amanprana-serum-gezicht-shangri-la.html</a> - works</p>
  
  <p><a href="https://amanvida.eu/nl/amanprana-serum-gezicht-shangri-la.html" rel="nofollow">https://amanvida.eu/nl/amanprana-serum-gezicht-shangri-la.html</a> - redirects to the home page</p>
  
  <p>So 3 out of 4 situations are already working fine, but I want the case where the user is already on the https site but not on the www. domain to also redirect correctly to the page, and not to the home page. </p>
  
  <p>I even tried forcing www like this:</p>
  
  <pre><code># First force domain to use www.
  RewriteCond %{HTTPS} off
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  RewriteCond %{HTTPS} on
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  </code></pre>
  
  <p>Without success.</p>