We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Micro application - "/" not found

I generated micro application from developer tools and when I request "localhost" it gives me "Not found :( This page is located in views/404.phtml ". However, in app.php is GET "/" defined to echo index.phtml. But if i add in app.php GET "/url" and put in it echo "you requested url", it works. Just root is not working and throwing 404. Have anyone experienced this strangeness? Thank you.

Using Phalcon 2.0.3 from 2.0.x branch, Apache 2.4 and Ubuntu 15.04. Rewrites are working.



4.0k

Can you paste code?

edited Jun '15

I didn't change anything except app.php. Code was generated by developer tools with type micro, but anyway, app.php:

<?php
/**
 * Local variables
 * @var \Phalcon\Mvc\Micro $app
 */

/**
 * Add your routes here
 */
 // not working, redirect to notFound
$app->get('/', function () use ($app) {
    echo $app['view']->render('index');
});
// working
$app->get('/lol', function () use ($app) {
    echo $app['view']->render('index');
});
/**
 * Not found handler
 */
$app->notFound(function () use ($app) {
    $app->response->setStatusCode(404, "Not Found")->sendHeaders();
    echo $app['view']->render('404');
});


4.0k

This code fragment are good. Double check other files.