php - CakePHP Redirect 404s -
i'm trying larn cakephp first time (i straight code php), , i'm starting 'official' blog tutorial host: http://book.cakephp.org/1.3/en/the-manual/tutorials-examples/blog.html
so far, i've setup virtual host (on os x 10.8.2), , used cakephp's default index page create sure it's reading database correctly, app/tmp folder recursively writeable apache, etc.
i run issues when seek follow blog right after initial posts view setup, , says can view posts @ (adjusting 'www.example.com' local servername) 'cakeblog/posts/index'. i'm pretty sure i'm having kind of mod_rewrite issue, can't figure out what. apache error logs whenever happens are:
[thu feb 14 09:18:10 2013] [error] [client 127.0.0.1] file not exist: /users/bailey/sites/cakeblog/posts [thu feb 14 09:18:10 2013] [error] [client 127.0.0.1] file not exist: /users/bailey/sites/cakeblog/favicon.ico i know favicon exists in webroot folder @ /users/bailey/sites/cascade/extranet-cake/app/webroot. if i'm understanding routing right, cakeblog/posts/index should controller post postscontroller, , /index should action/method in postscontroller "index()". seems not recognizing controller?
the code have setup next blog tutorial is:
(app/model/post.php):
<?php /* model: represents info model (object). examples -> blog, post, comment on post */ class post extends appmodel { } ?> (app/controller/postscontroller.php):
<?php /* plays posts model , gets work done. - function "foo()" means function accessed going domain/posts/foo */ class postscontroller extends appcontroller { public $helpers = array('html', 'form'); // action! // www.example.com/posts/index => listing of posts /* sets view variable called ‘posts’ equal homecoming value of find('all') method of post model. */ public function index() { $this->set('posts', $this->post->find('all')); } } ?> (app/view/posts/index.ctp):
<!-- /app/view/posts/index.ctp --> <h2> blog posts </h2> <table> <tr> <th> id </th> <th> title </th> <th> date created </th> </tr> <!-- output actual posts --> <?php foreach ($posts $post) { /* info ~ $post[modelname][variablename] */ $id = $post['post']['id']; /* "$this->html" ~ helper link() generates html link given title , url */ $titlelink = $this->html->link($post['post']['title'], array('controller' => 'posts', 'action' => 'view', $post['post']['id'])); $datecreated = $post['post']['created']; $out = "<tr> <td>$id</td> <td> $titlelink </td> <td>$datecreated</td> </tr>"; echo $out; } unset($post); ?> </table> this first time i've seen cakephp , can't find solutions in of other posts, except circumstantial reasons suspect mod_rewrite issue. have ideas on i'm missing? can post httpd.conf file, too, upon request.
[solved]
stupid error -- turns out using subfolder other app/webroot webroot. 1 time changed worked fine.
an alternative if wanted utilize webroot different default given jeremyharris in comments above , supported in cakephp docs:
http://book.cakephp.org/1.3/en/the-manual/developing-with-cakephp/installation.html
thanks help, everyone!
php cakephp mod-rewrite http-status-code-404
No comments:
Post a Comment