title: Force HTTPS on certain URLs and force HTTP for all others
body: <p>I have a client project where I need to force HTTPS for a certain folder and force HTTP for all others. I can sucessfully enforce HTTPS for the folder I desire but then all links back to the rest of the site end up being through HTTPS. I'd like to have a rule which forces requests for anything 'not' in the secure folder to be forced back to HTTP. Here's what I have so far:</p>
  
  <pre><code>RewriteEngine On
  RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
  
  RewriteCond %{HTTPS} !=on
  RewriteRule ^(my) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1
  </code></pre>
  
  <p>'my' is the name of the folder that I need to force HTTPS for.</p>
  
  <p>Any ideas?</p>
  
  <p>Update: I also tried:</p>
  
  <pre><code>RewriteEngine On
  RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
  
  # Force HTTPS for /my
  RewriteCond %{HTTPS} !=on
  RewriteRule ^(my) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
  
  # Force HTTP for anything which isn't /my
  RewriteCond %{HTTPS} =on
  RewriteRule !^my http://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
  
  # Remove index.php from URLs
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1
  </code></pre>
  
  <p>But instead of requests for /my being forced through HTTPS they now just resolve to <a href="http://www.example.com/index.php/my" rel="noreferrer">http://www.example.com/index.php/my</a></p>
  
  <p>:?</p>