title: htaccess force www and keep trailing url
body: <p>I am using the following to redirect my non www. urls to use www.:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
  
  &lt;/IfModule&gt;
  &lt;IfModule mod_headers.c&gt;
  Header set Access-Control-Allow-Origin "http://www.domain.com/"
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>However, if someone visits domain.com/abc-123 it redirects to www.domain.com and loses the remaining of the url.</p>
  
  <p>Any help with this? How can i set it up so it doesn't remove the end of the url?</p>
  
  <p>Miro</p>