title: htaccess rewritecond
body: <p>We have a domain name with various TLDs.</p>
  
  <p>Let's use example.com as our main URL, and we redirect example.biz, example.net, example.org to example.com.</p>
  
  <p>We had the following in .htaccess file and it worked very well:</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
  RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  </code></pre>
  
  <p>You notice that any non-www will be redirected to www.</p>
  
  <p>However, we just added a subdomain: str.example.com, and in order to make it accessible, we had to comment out the above rules.</p>
  
  <p>I hope someone can help us to write the rules that will redirect:</p>
  
  <ol>
  <li>non-www and non-str to www</li>
  <li>non-.com TLDs to .com</li>
  </ol>
  
  <p>Several cases to make my means clear:</p>
  
  <ol>
  <li>example.com -> www.example.com</li>
  <li>example.net -> www.example.com</li>
  <li>abc.example.com -> www.example.com</li>
  <li>str.example.com -> str.example.com</li>
  <li>str.example.org -> str.example.com</li>
  </ol>
  
  <p>Thank you very much.</p>