title: .htaccess: force www on all pages, force https on one page, force http on all other pages
body: <p>I have this site, example.com. What I want to do is force www on all pages, force https on one page, force http on all other pages.</p>
  
  <p>I am using the following .htaccess code to redirect all http traffic to www: </p>
  
  <pre><code>#Redirect to www
  RewriteCond %{HTTP_HOST} ^example.com$ [NC]
  RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
  </code></pre>
  
  <p>and the following to set SSL on my "form" page: </p>
  
  <pre><code>#Force SSL on a specific directory
  RewriteCond %{ENV:HTTPS} !on [NC]
  RewriteCond %{REQUEST_URI} form
  RewriteRule ^(.*)$ https://www.example.com/form/$1 [R,L]
  </code></pre>
  
  <p>Problem is, when I hit <a href="https://example.com/" rel="nofollow">https://example.com/</a>, it does not redirect to www (<a href="https://www.example.com" rel="nofollow">https://www.example.com</a>), and especially not http and www (<a href="http://www.example.com" rel="nofollow">http://www.example.com</a>) like I want it to. I tried this:</p>
  
  <pre><code>#Redirect SSL to www
  RewriteCond %{ENV:HTTPS} on [NC]
  RewriteRule ^(.*)$ http://www.example.com$1 [R=permanent,L]
  </code></pre>
  
  <p>but that was a really dumb attempt and didn't work. How can I accomplish all three at once?</p>