title: Redirect To www from non www site for subfolder using .htaccess
body: <p>I want to redirect from <a href="http://domain.com/folder/" rel="nofollow">http://domain.com/folder/</a> to <a href="http://www.domain.com/folder/" rel="nofollow">http://www.domain.com/folder/</a></p>
  
  <p>I have tried below code</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^domain.com [nc]
  RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
  </code></pre>
  
  <p>AND</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} domain.com [NC]
  RewriteRule ^(.*)$ http://www.domain.com/folder/index.html [R=301,NC]
  </code></pre>
  
  <p>It redirects to <a href="http://domain.com/" rel="nofollow">http://domain.com/</a> to <a href="http://www.domain.com/" rel="nofollow">http://www.domain.com/</a>
  Not <a href="http://domain.com/folder/" rel="nofollow">http://domain.com/folder/</a> to <a href="http://www.domain.com/folder/" rel="nofollow">http://www.domain.com/folder/</a></p>
  
  <p>also it redirect to <a href="http://domain.com/folder/" rel="nofollow">http://domain.com/folder/</a> to <a href="http://www.domain.com/" rel="nofollow">http://www.domain.com/</a>
  But not to <a href="http://www.domain.com/folder/" rel="nofollow">http://www.domain.com/folder/</a></p>
  
  <p>Please suggest what issue and help to solve it.
  Thanks.</p>