title: .htaccess: redirect http to https or https to http depending on URL
body: <p><strong>The solution below covers required rules:</strong></p>
  
  <p>1) <code>http://www.mydomain.com , http://www.mydomain.com/?p=home , http://www.mydomain.com/?p=home1 , http://www.mydomain.com/?qqq=home</code> are always http, even if https are typed instead of http;</p>
  
  <p>2) all the rest pages are always https, even if http was typed instead of https;</p>
  
  <p><strong>but in practice does NOT cover</strong></p>
  
  <p>3) <code>//www.mydomain.com/administration/any_file_in_admin_folder.php</code> should always be https as well (even with parameter ?p=home etc).</p>
  
  <pre><code>RewriteEngine on
  RewriteBase /
  
  #determine if page is supposed to be http
  #if it has p=home or p=home1 or qqq=home in querystring
  RewriteCond %{QUERY_STRING} (^|&amp;)(p=home1?|qqq=home)(&amp;|$) [NC,OR]
  #or if query string is empty
  RewriteCond %{QUERY_STRING} ^$
  #set env var to 1
  RewriteRule ^ - [E=IS_HTTP:1]
  
  
  #all pages that are supposed to be http redirected if https
  RewriteCond %{HTTPS} on
  RewriteCond %{ENV:IS_HTTP} 1
  RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  
  #all other pages are sent to https if not already so
  RewriteCond %{HTTPS} off
  RewriteCond %{ENV:IS_HTTP} !1
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  </code></pre>
  
  <p>How to implement 3) to this code so it works? (I still have no luck and need help).
  Thank you.</p>