+91-943-185-6038 me@shashidharkumar.com

How to redirect from non-www to www in CakePHP?

Put the following code into .htaccess in main directory


  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
  RewriteCond %{HTTP_HOST} !=localhost [NC]
  RewriteCond %{HTTP_HOST} !=127.0.0.1
  RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]



   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]

See also  How to add custom post type in wordpress