title: redirect all non www to www. for Cakephp site
body: <p>Hi allm i'm having some issues in redirecting the non www pages to the www. pages for my cakephp site.</p>
  
  <p>I've tried</p>
  
  <pre><code>Options +FollowSymlinks
  RewriteEngine on
  rewritecond %{http_host} ^domain.com [nc]
  rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
  </code></pre>
  
  <p>but it doesn't seem to work.</p>
  
  <p>My cakephp app resides in a subfolder. eg. <code>www.domain.com/my</code>. </p>
  
  <p>i've added the above code to the root folder, <code>www.domain.com/</code></p>
  
  <p>any suggestions? thanks?</p>
  
  <p>*update</p>
  
  <p>This my .htaccess file</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
  
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
  &lt;/IfModule&gt;
  
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
  RewriteRule ^.*$ http://www.domain.com%{REQUEST_URI} [R=301,L]
  </code></pre>
  
  <p>i'm getting an extra <code>webroot/index.php?url=</code> inserted into the url. Instead of <code>www.domain.com/my/apple</code>, i'm getting <code>www.domain.com/my/webroot/index.php?url=apple</code> </p>
  
  <p>thanks to all once again.</p>