title: Redirect all http AND https non-www URLS to https://www.xyz.com via htaccess
body: <p>For reasons much too long and complex to get into (it involves several layers of corporate red tape resulting in someone else not purchasing a wildcard SSL certificate I requested), I have to set up a domain to redirect all requests to <a href="https://www.xyz.com">https://www.xyz.com</a> – secure protocol with the <code>www</code> subdomain.</p>
  
  <p>So: <a href="http://xyz.com">http://xyz.com</a>, <a href="http://www.xyz.com">http://www.xyz.com</a>, and <a href="https://xyz.com">https://xyz.com</a> should ALL redirect to <a href="https://www.xyz.com">https://www.xyz.com</a>.</p>
  
  <p>My .htaccess-fu is weak at best and I can't seem to get this to work. Note: hosting is on Media Temple if that makes a difference.</p>
  
  <p>So far, my .htaccess file looks like so:</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTPS} !^on$
  RewriteRule (.*) https://www.xyz.com/$1 [R,L]
  
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
  </code></pre>
  
  <p>Both <a href="http://xyz.com">http://xyz.com</a> and <a href="http://www.xyz.com">http://www.xyz.com</a> are redirecting to <a href="https://www.xyz.com">https://www.xyz.com</a>, so yay. However, <a href="https://xyz.com">https://xyz.com</a> is <em>not</em> redirecting to <a href="https://www.xyz.com">https://www.xyz.com</a> and is thus throwing a security warning page:</p>
  
  <blockquote>
    <p><strong>This is probably not the site you are looking for!<br></strong>
    You attempted to reach <strong>xyz.com</strong>, but instead you actually reached a server identifying itself as <strong>www.xyz.com</strong>. This may be caused by a misconfiguration on the server or by something more serious. An attacker on your network could be trying to get you to visit a fake (and potentially harmful) version of <strong>xyz.com</strong>.<br>
    You should not proceed, especially if you have never seen this warning before for this site.</p>
  </blockquote>
  
  <p>Any help in getting me past this one final hump would be muchly appreciated!</p>