Discussion:
Page Not Found Error In cake_1.2.0.7296-rc2
amit_2006_it
2008-07-24 17:00:00 UTC
Permalink
Hi,

I am new to cakePHP world that's why i try to started with the blog
tutorial shown on cakephp.org. But whenever i hit the browser with
http://localhost/cakeBlog/posts/index,
i get an error "Not Found. The requested URL /cakeBlog/posts/index was
not found on this server.".

Here is what i made to get it worked....

1. first created the app/models/post.php
=> class Post extends AppModel
{
var $name = "Post";
}
2. Secondly, add controller in app/controllers/posts_controller.php
=> class PostsController extends AppController
{
$name = "Posts";

function index()
{
$this->set("posts", $this->Post->findAll());
}
}

3. Finally print the array assign to "posts" variable in controller
page shown above in app/views/posts/index.ctp
=> print_r($posts);

Now as it is exactly shown in the blog tutorial on cakephp.org, it
should work.
But its not. And i wasted lot of time to find out what went wrong.

Please tell me, is there something wrong in this code?

Thank you,
Amit Gharat
amit.2006.it-dVM3bRS+***@public.gmane.org
amit_2006_it
2008-07-26 13:45:17 UTC
Permalink
Hi Daniel,

Thank you for replying. But i don't think, there may be a mod_rewrite
issue, because when i used same code with the older version of cakephp
(cake 1.9.9), it worked fine without any mod_rewrite issue.

Is there any changes need to be made in routes.php page?

Regards
Amit Gharat
amit.2006.it-***@public.gmane.org
Smelly_Eddie
2008-07-28 13:04:16 UTC
Permalink
How is your web server setup Amit.

Are you setting the top level folder(cake) as your active directory,
or are you using webroot folder as the active directory?

Can you see styles on the page (like DH asked, this can clearly
indicate trouble with htaccess and modrewrite)?

Is CakePHP's error output on? (which may explain the abbreviated error
message as appose to cake's helpful ones)


You should not need to make any changes to routes.php unless you want
to add new functionality/paths
It seems like a web server configuration issue. If you're getting the
standard "404 error" as opposed to cakePHP's error page, it seems like
your URL rewriting is not working properly. Perhaps the .htaccess file
got deleted?
Post by amit_2006_it
Hi Daniel,
Thank you for replying. But i don't think, there may be a mod_rewrite
issue, because when i used same code with the older version of cakephp
(cake 1.9.9), it worked fine without any mod_rewrite issue.
Is there any changes need to be made in routes.php page?
Regards
Amit Gharat
amit_2006_it
2008-08-01 09:37:41 UTC
Permalink
Thank you guys for sharing such a useful information.
But i got a solution myself...

I forgot to make changes in routes.php As

default: Router::connect('/', array('controller' => 'pages',
'action' => 'display', 'home'));
changed to: Router::connect ('/', array('controller'=>'posts',
'action'=>'index'));

And it worked!!!
atillakurucan
2008-08-25 14:50:53 UTC
Permalink
Mine hasn't worked yet. I followed this conversation but I didn't get
right solution. When I change the default value of
Router::connect(...), cakePHP welcome page doesn't work either. What
else can I check?
Post by amit_2006_it
Thank you guys for sharing such a useful information.
But i got a solution myself...
I forgot to make changes in routes.php As
default:        Router::connect('/', array('controller' => 'pages',
'action' => 'display', 'home'));
changed to: Router::connect ('/', array('controller'=>'posts',
'action'=>'index'));
And it worked!!!
Zedix
2008-07-27 16:29:43 UTC
Permalink
It seems like a web server configuration issue. If you're getting the
standard "404 error" as opposed to cakePHP's error page, it seems like
your URL rewriting is not working properly. Perhaps the .htaccess file
got deleted?
Post by amit_2006_it
Hi Daniel,
Thank you for replying. But i don't think, there may be a mod_rewrite
issue, because when i used same code with the older version of cakephp
(cake 1.9.9), it worked fine without any mod_rewrite issue.
Is there any changes need to be made in routes.php page?
Regards
Amit Gharat
Continue reading on narkive:
Loading...