title: .htaccess redirect without affecting subdomain
body: <p>I have our main website <a href="https://www.example.com.au" rel="nofollow">https://www.example.com.au</a> inside home/user/public_html and a subdomain which lives in home/user/sub <a href="https://sub.example.com.au" rel="nofollow">https://sub.example.com.au</a></p>
  
  <p>They are both Joomla websites. </p>
  
  <p>Inside home/user/public_html I have the below .htaccess file which I use to make every page visit of our main website use https and www - the code used is:</p>
  
  <pre><code>RewriteEngine On
  
  RewriteCond %{HTTPS} off
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301,L]
  
  RewriteCond %{HTTPS} off
  RewriteCond %{HTTP_HOST} ^www\.
  RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
  
  RewriteCond %{HTTPS} on
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301,L]
  </code></pre>
  
  <p>This above .htaccess file is redirecting all subdomain visits to https:// www. sub.example.com.au - how can I stop it doing so, and at the same time for it to load all the subdomain visits to https: //sub. example.com.au</p>
  
  <p>I thought that the .htaccess file would only affect directories within it, but it seems to be affecting the subdomain even though it isn't within the public_html folder. </p>
  
  <p>Any advise appreciated. Thanks.</p>
  
  <p>Note had to put spaces in some of the links above as I don't have enough reputation.</p>