title: Redirect non-www to www in .htaccess
body: <p>I have this in my .htaccess file:</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^example.com$
  RewriteRule (.*) http://www.example.com$1 [R=301,L]
  </code></pre>
  
  <p>but whenever I access a file on my root like <code>http://example.com/robots.txt</code> it will redirect to <code>http://www.example.comrobots.txt/</code>.</p>
  
  <p>How can I correct this so that it will redirect correctly to <code>http://www.example.com/robots.txt</code>?</p>