title: How do I enable https only on certain pages with htaccess?
body: <p>I have an ecommerce site, and I want to enable https only on the ecommerce section of the site located at <a href="https://mysite.com/buy" rel="nofollow">https://mysite.com/buy</a></p>
  
  <p>Since all of the links on my pages are relative, when someone visits <a href="http://mysite.com" rel="nofollow">http://mysite.com</a> and clicks on Buy, they are taken to <a href="http://mysite.com/buy" rel="nofollow">http://mysite.com/buy</a></p>
  
  <p>Also, if they visit <a href="https://mysite.com/buy" rel="nofollow">https://mysite.com/buy</a> and click on a link to another page, they are taken to <a href="https://mysite.com" rel="nofollow">https://mysite.com</a>.</p>
  
  <p>The reason I want https only on that one section is because I have external elements (i.e. Google Maps, Youtube, Twitter, etc) that cannot be sent over https.</p>
  
  <p>Is there a way with htaccess that I can make the /buy directory force https, but every other page force http?</p>
  
  <p>Edit:
  In case anyone is interested, I was able to solve this using PHP. I would still prefer an htaccess solution, but this will work for now:</p>
  
  <pre><code>if($_SERVER['HTTPS'] == "on") {
      if(strpos($_SERVER['REQUEST_URI'],"buy") === false) {
          Header("Location: http://$_SERVER['HTTP_HOST']."".$_SERVER['REQUEST_URI']");
      }
  }
  </code></pre>