Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon 2 nginx Router only index controller loaded

I started a new app using Phalcon 2, mostly by following the tutorial. I am using nginx set as here: The router always loads the index controller and template.

$router = new Phalcon\Mvc\Router(false); $router->setUriSource(Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);

Also tested with the default $_GET['_url']

$router->add("/", array( 'controller' => 'index', 'action' => 'index' ));

Added the same route different ways (only one active, two commented out), even tried with double slashes or without any.

$router->add("/signup", array( 'controller' => 'signup', 'action' => 'index' ));

$router->add("/signup", 'Signup::index'); $router->addGet("/signup", 'Signup::index');

The debugging here shows string(7) "/signup" so I don't think it's an nginx problem.


This one is null.


This one returns an array with two Phalcon\Mvc\Router\Route objects.


This one is also null.

var_dump($router->getControllerName ());

I have the signup template and controller, but it's only loading the index one.


I'm using phalcon 2 with nginx and it works fine. Post you nginx configuration for your website.

edited Dec '14

I don't think the problem is with nginx's config (the config is copy paste with root edited), because var_dump($router->getRewriteUri()); prints string(7) "/signup" I also used the config where I had the rewrite index.php?_url=/$1 and var_dump($router->getRewriteUri()); printed string(8) "//signup" I installed phalcon 2 last month, so I don't think I have the latest updates.


My bad, I had the index.phtml template directly in the views folder. not in views/index. The loaded controller was SignupController, but the template was index.phtml. I created the index folder, moved the file and it's ok now.