title: using htaccess to redirect http and https based on conditions
body: <p>I want to redirect everything except an url to HTTPS and redirect the specific url to HTTP</p>
  
  <p>I used the following apache config:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteCond %{SERVER_PORT} !^443
      RewriteCond %{REQUEST_URI} !^/url
      RewriteRule ^ https://mydomain.tld%{REQUEST_URI} [R=301,L]
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_rewrite.c&gt;
      RewriteCond %{SERVER_PORT} ^443
      RewriteCond %{REQUEST_URI} ^/url
      RewriteRule ^ http://mydomain.tld%{REQUEST_URI} [R=301,L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Unfotunately it just loop forever in the redirections and I can't figure out the correct rewritecond conditions to make it work properly</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>I also have these rules beside that might influence something I guess... :</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      Options -Multiviews +SymLinksIfOwnerMatch
      RewriteEngine On
      RewriteBase /
      DirectorySlash Off
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_rewrite.c&gt;
      RewriteCond %{HTTPS} !=on
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_rewrite.c&gt;
      RewriteCond %{SCRIPT_FILENAME} -d [OR]
      RewriteCond %{SCRIPT_FILENAME} -f
      RewriteRule "(^|/)\." - [F]
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_headers.c&gt;
      Header set Strict-Transport-Security "max-age=16070400; includeSubDomains"
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_rewrite.c&gt;
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
  &lt;/IfModule&gt;
  </code></pre>