title: Apache detected external loop redirection with target URL after .htaccess setup
body: <p>I've played around with this for hours, trying to get it right. It seems to be working the way I want, but I'm getting this Apache error. </p>
  
  <p>I want to set it up so if someone visits my main URL they're directed to https and www, so I have this in the htaccess file in the main public_html directory. </p>
  
  <pre><code>Options +FollowSymLinks
  RewriteEngine On
  RewriteCond %{HTTP_HOST} !^www.domain.com
  RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
  
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
  </code></pre>
  
  <p>Next I want anyone who hits subdomain.domain.com or domain.com/subdomainname to redirect to <a href="https://subdomain.domain.com" rel="nofollow">https://subdomain.domain.com</a>, so I have this in the .htaccess file in the subdomain folder. </p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www\.subdomain\.domain\.com$
  RewriteRule ^/?$ "https\:\/\/subdomain\.domain\.com\/" [R=301,L]
  </code></pre>
  
  <p>Any hints as to what I'm doing wrong? </p>