I've just finished the Getting started tutorial (http://book.cakephp.org/2.0/en/getting-started.html) and put my files on an Apache server, that has Drupal projet as root URL.
The Cakephp's index page loads fine, but when I click on any item, changing my root url to something like root/posts/view/2
, it displays Drupal's page not found error.
I guess it may be a rewrite problem. My CakePHP directory has an .htaccess file containing :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
And my apache2 sites-enabled conf ends with :
Alias /test /var/www/cakephp/app/webroot
<Directory /var/www/cakephp/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
When I change the index action route from :
Router::connect('/', array('controller' => 'posts', 'action' => 'index'));
to :
Router::connect('/foo', array('controller' => 'posts', 'action' => 'index'));
I've got the same error as described above.
Any clue ?
I think the problem came from Rewrite mod. Removing the 3 .htaccess files allowed me to access the app urls.
By the way, I tried on a fresh clean Apache server with the following .htaccess files and it worked :
/var/www/cakephp/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cakephp/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/var/www/cakephp/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cakephp/app/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/var/www/cakephp/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cakephp/app/webroot/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>