0

I did all the settings to not use mod_rewrite Apache 2.2 and CakePHP.

Apache2 is up and running and Cake seems to be running too. If I go http://127.0.0.1/cake/index.php, all green tags along (using PostgreSQL 9.1). I followed the tutorial to create the blog project and created the controller file at /var/www/cake/app/Controller/PostsController.php (also has CakeController and AppController and PagesController files).

In the Model dir I got Post.php and AppModel, as the tutorial said. And in the View folder, I created Posts folder and the files index.ctp and view.ctp.

When I type an url like http://127.0.0.1/cake/index.php?url=/posts/ it goes to index.php of the Cake main folder. It redirects to there! If I change the URL for example to http://127.0.0.1/cake/index.php?url=/posts/view/1 (like the tutorial) same thing. What went wrong in this picture?

My environment is Debian 6.0-6 64bits. Apache2.2 (installed with SO), CakePHP 2.2.3 and PHP 5.2.8 (or higher).

Joseph Quinsey
  • 9,553
  • 10
  • 54
  • 77
jose mey
  • 81
  • 1
  • 1
  • 8

1 Answers1

1

Are you sure that mod_rewrite is on and rewriting? Can you post the contents of your .htaccess files - the one in the top level dir (i.e. htdocs) and the one in your app/webroot dir? Your top-level dir is the one with app and lib in it. I suspect your RewriteRule's are wrong in both. Anyway if you haven't changed those files it will definately be wrong. :) You shouldn't change the middle .htaccess file - the one in app.

This is already answered here and the CakeBook explains it here. But I personally use a bit different set-up:

/var/www/test.cake.lan/htdocs/.htaccess

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

/var/www/test.cake.lan/htdocs/app/.htaccess

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

/var/www/test.cake.lan/htdocs/app/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /app/webroot/index.php?url=$1 [QSA,L]
</IfModule>
Community
  • 1
  • 1
Borislav Sabev
  • 4,776
  • 1
  • 24
  • 30
  • Dude, ty VM for yr answer but i think u missread... As i said my goal is NOT use mod_rewrite. So as explained i uncomment a line and delete all .htaccesss (actually i renamed all, but) and i used url´s as mentioned b4. – jose mey Nov 03 '12 at 13:55
  • 1
    Anyways, i appeciatte the answer... Yr links led me to learn more. – jose mey Nov 03 '12 at 13:56