title: CakePHP htaccess for removing www
body: <p>I know that too much questions exist for htaccess redirection, but I couldn't find the exact solution. I'm sorry if there exist a matching question.</p>
  
  <p>In my public html (webroot) folder there was following htaccess file:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ index.php [QSA,L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Then to redirect URLs with "www" to "non-www" I added two lines. And file became like this:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ index.php [QSA,L]
  
      RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
      RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
  
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>So the problem is,
  <strong>www.example.com</strong>   redirects to <strong>example.com</strong>
  but  <strong>www.example.com/mycontroller/</strong> weren't redirected to <strong>example.com/mycontroller/</strong></p>
  
  <p>How can I solve this?</p>