title: .htaccess redirect https to http except one page along with www to non-www
body: <p>on one of my domain i am using htaccess </p>
  
  <pre><code>RewriteCond %{SERVER_PORT} ^443$  [OR]
  RewriteCond %{HTTPS} on [OR]
  RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
  RewriteRule (.*) http://example.com/$1 [R=301,L] 
  </code></pre>
  
  <p>Which redirect all https to http as well as www to non-www domain.</p>
  
  <p>Now, i want secure.php page to use https protocol instead of http protocol also with redirection of www to non-www.</p>
  
  <p>i can use below lines to acheive this...</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
  RewriteRule (.*) http://example.com/$1 [R=301,L]
  
  RewriteCond %{HTTPS} off
  RewriteCond %{SCRIPT_FILENAME} \/secure\.php [NC]
  RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
  
  RewriteCond %{HTTPS} on
  RewriteCond %{SCRIPT_FILENAME} !\/secure\.php [NC]
  RewriteRule (.*) http://%{HTTP_HOST}/$1 [R=301,L] 
  </code></pre>
  
  <p>in my first htaccess if user access <a href="https://www.example.com" rel="nofollow">https://www.example.com</a> then in redirects to <a href="http://example.com" rel="nofollow">http://example.com</a> in single redirect.</p>
  
  <p>after modification to secure secure.php page, on second htaccess consider case if user access <a href="http://www.example.com/secure.php" rel="nofollow">http://www.example.com/secure.php</a> ->redirects to <a href="http://example.com/secure.php" rel="nofollow">http://example.com/secure.php</a> -> redirect to <a href="https://example.com/secure.php" rel="nofollow">https://example.com/secure.php</a>
  here i get two redirects.</p>
  
  <p>Pls suggest how can i club my criteria like in my first htaccess using [OR], so than in all cases it uses atmost one redirect to reach final page.</p>