title: Redirect in htaccess to folder and https
body: <p>Using htaccess I want to force http to https and at the same time redirect to www. and to the 'public' folder where my application files are. 
  The result should be that <code>http://example.com</code> should redirect to <code>https://www.example.com/public/</code></p>
  
  <p>To redirect to https and www I manage by using:</p>
  
  <pre><code>RewriteCond %{HTTPS} off 
  RewriteCond %{HTTP_HOST} !^www\. [NC] 
  RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] 
  RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
  </code></pre>
  
  <p>To redirect to the 'public' folder I manage by using:</p>
  
  <pre><code>ReWriteCond %{REQUEST_URI} !^public/
  ReWriteRule ^(.*)$ public/$1 [L]
  </code></pre>
  
  <p>Now I need to combine these but my many attempts did not result in a working redirect and I would need some advise on this.</p>
  
  <p>EDIT:
  In the folder public is another htaccess file:</p>
  
  <pre><code> SetEnv APPLICATION_ENV "production"
   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} -s [OR]
   RewriteCond %{REQUEST_FILENAME} -l [OR]
   RewriteCond %{REQUEST_FILENAME} -d
   RewriteRule ^.*$ - [NC,L]
   RewriteRule ^.*$ /index.php [NC,L]
  </code></pre>
  
  <p>&lt;&lt;</p>