title: .htaccess / https redirection, virtual folder access with exceptions
body: <p>/* THIS would appear to be a duplicate of another question I had asked 10 days back (<a href="https://stackoverflow.com/questions/1601876/htaccess-redirecting-to-https-www-mydomain-com-and-virtual-folder-access">.htaccess / redirecting to https://www.example.com and virtual folder access</a>), but (a) I didnt get any responses to the changes I made to the question, and (b) this question here is a more complex version of the above and I believe warrants a new query */</p>
  
  <p>I have a site which has the following entities:
  example.com/index.html
  example.com/main.php
  example.com/SPECIAL/main.php
  besides the above, I have folders like example.com/images/, /css/, etc which the html generated by the scripts point to.</p>
  
  <p>I need .htaccess magic for ALL of the below:<br/><br/>
  (a) permanently redirecting users from "example.com" to "www.example.com" (301 stuff)<br/><br/>
  (b) permanently redirecting users from <a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a> to <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a> (301 stuff)<br/><br/>
  (c) users accessing example.com/ should, of course, see index.html, but if they type<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;example.com/ABCDEF OR<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;example.com/ABCDEF/<br/> they should be redirected to example.com/main.php?folder=ABCDEF<br/>EXCEPT when ABCDEF is a real folder (like /SPECIAL/, /images/, /css/, etc)<br/><br/>
  (d) If user tries to access example.com/REALFOLDER/ (eg /images/), he should just be redirected to example.com/<br/><br/>
  (e) All of this should not mess with the viewing of example.com/index.html<br/><br/></p>
  
  <p>Sorry if this sounds complex, but thats exactly what I need!</p>
  
  <p>S</p>