Deploy CakePHP to a subfolder

Posted by mgroves on Stack Overflow See other posts from Stack Overflow or by mgroves
Published on 2012-10-21T16:56:23Z Indexed on 2012/10/21 17:00 UTC
Read the original article Hit count: 262

I have created a CakePHP 2 app, and now I'm trying to deploy it to a production web server.

My app uses the default folder structure (app/lib/plugins/vendors), default htaccess, default routing, nothing special.

I've been developing locally as if the app were in the root folder of the site (e.g. http://mycakeapp.localhost/ takes me to the site). But I'm deploying to a site (shared hosting) where that will not be the case (e.g. http://www.somedomain.com/mycakeapp).

It doesn't work (I didn't really expect it to), so I assumed I had to tweak one or more htaccess files. I tried modifying the root .htaccess as suggested in this post, but that only partially worked (the link to the CSS didn't work, for instance):

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule  ^mycakeapp$  mycakeapp/app/webroot/  [L]
RewriteRule  ^mycakeapp/(.*)$  mycakeapp/app/webroot/$1  [L]
</IfModule>

So what should I do to all the htaccess files to make this CakePHP site work in a subfolder?

© Stack Overflow or respective owner

Related posts about apache

Related posts about .htaccess