title: .htaccess for 301 rewrite for www/non www canonical, with exceptions for subfolder (another domain)
body: <p>I have a domain and host it on godaddy.com. I have firstsite.com which is in the root of the hosting account. I have an .htaccess file for this site which works fine, and does a simple redirect of all <code>firstsite.com</code> traffic to <code>www.firstsite.com</code>. It is </p>
  
  <pre><code>RewriteEngine On
  
  RewriteCond %{HTTP_HOST} !^www\.firstsite\.com$ 
  RewriteRule (.*) http://www.firstsite.com/$1 [R=301,L] 
  </code></pre>
  
  <p>However, I have added a new domain to my hosting account, which is contained within a subfolder on the site: <code>/secondsite</code></p>
  
  <p>Without the .htaccess file, when I go to <code>secondsite.com</code> it displays as <code>secondsite.com</code>. However, with the .htaccess file, it displays as <code>www.firstsite.com/secondsite</code>.</p>
  
  <p>I would like to have the www/non www canonical .htaccess work for the first site, but still have the second site displaying correctly, also with www/non www canonical resolved. </p>
  
  <p>I have searched everywhere for this specific issue, but have not found how to code the .htaccess file. Can someone give me a quick example of how to do that?</p>