title: Apache to force certain URL for HTTP and all others go via https
body: <p>First i have to say I found many answers for revise situation but not for this.</p>
  
  <p>Apache to force certain URL for HTTP and all others go via https.
  Would like to get expert knowledge on following. Thanks for all of your time and appreciate that.</p>
  
  <p>We have apache fronting tomcat in our production environment and we would like to enable https for all the incoming except for few pages and would like help on writing  solid apache rewrite rule to do this .
  That is </p>
  
  <ol>
  <li>All incoming connection go via https except for some pages (/abc, /def, /ghi) to force http.</li>
  </ol>
  
  <p>Any help. I came up with this with help of google  but its not working for http. All traffic goies to https </p>
  
  <pre><code>RewriteCond %{HTTPS} off
  RewriteCond %{REQUEST_URI} !^/(/abc|/def|/ghi)
  RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
  
  RewriteCond %{HTTPS} on
  RewriteCond %{REQUEST_URI} ^/(/abc|/def|/ghi)
  RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
  </code></pre>