CakePHP is designed to be installed into a webroot directory. The .htaccess files are pre-configured to make everything work out of the box ...
... except in my setup. I have installed CakePHP into a subdirectory of my development root. This seems to confound CakePHP - which is possibly due to some Apache settings.
I have my development in a subdirectory of my home:
/home/raymond/dev/workspace
. My Apache configuration sets this as the root for http://localhost/dev/:
Alias /dev "/home/raymond/dev/workspace
<Directory "/home/raymond/dev/workspace">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I use Eclipse, so this seems to make sense. This means I can have
/home/raymond/dev/workspace/birthclass
for the birthclass site development, and now:
/home/raymond/dev/workspace/cakephp
for the CakePHP experiment. All fairly logical so far ...
... when having followed a tutorial, all I get from Apache is:
The requested URL /home/raymond/dev/workspace/cakephp/app/webroot/ was not found on this server.
After some monkeying around, I have found the trick: edit the .htaccess files. There are three: in the CakePHP root, app and app/webroot. In each case, the RewriteBase must be defined. In my case, these are /dev/cakephp/, /dev/cakephp/app/ and /dev/cakephp/app/webroot/ respectively. So now, my cakephp/app/webroot/.htaccess file look like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dev/cakephp/app/webroot/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
And now I have a fully functioning CakePHP setup in its own subdirectory. When I request http://localhost/dev/cakephp, I get my CakePHP application. When I request http://localhost/birthclass, I get my
birthclass application.
Job done. On to the tutorials ...