title: mod_rewrite http to https ends up in loop
body: <p><br>
  I've got the problem that I want to redirect my HTTP requests to a HTTPS using a shared SSL certificate. For some stupid reason of my host I have to attach the SSL Port on the request url.
  Basically I want to redirect this:</p>
  
  <pre><code>http://sub.domain.com
  </code></pre>
  
  <p>to</p>
  
  <pre><code>https://sub.domain.com:12345
  </code></pre>
  
  <p>my .htaccess looks like this:</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTPS} =off
  RewriteRule ^(.*)$ https://%{HTTP_HOST}:12345%{REQUEST_URI} [L,R]
  </code></pre>
  
  <p>By this results in a redirect loop. I have no idea why though. Is this maybe because I use a shared SSL certificate which is not made for the domain and therefore the RewriteCond is always off?</p>
  
  <p>thanks in advance!</p>
  
  <p>EDIT:</p>
  
  <p>I've checked the response header and saw that the location field still points to the non https url. But if I use another domain (or even a subdomain) it works. So why doesn't work the redirect to the same domain?</p>