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.

Custom Routing working for '/' but no others

I have a very simple implementation that follows the docs and some things I've read, but I'm still stuck. Displaying the '/' route works, but the other routes (/login, /masses, /vendors) do not work... I get a 404 for all of them. AJAX routes are also broken, but I'd like to solve the page routes issue first.

Here is the code:


use Phalcon\Mvc\Router;

$router = new Router(false);

$router->addGet("/", [
    'controller' => 'noauth',
    'action'     => 'home',

$router->addGet("/masses", [
    'controller' => 'noauth',
    'action'     => 'masses',

$router->addGet("/vendors", [
    'controller' => 'noauth',
    'action'     => 'vendors',

$router->addGet("/login", [
    'controller' => 'noauth',
    'action'     => 'login'

return $router;


use Phalcon\Mvc\Controller;

class NoauthController extends Controller

    public function initialize() {

    public function homeAction() {

    public function loginAction() {
        echo "login";

    public function massesAction() {
        echo "masses";
    public function vendorsAction() {
        echo "vendors";



use Phalcon\Loader;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Mvc\Application;
use Phalcon\DI\FactoryDefault;

try {

    // Register an autoloader
    $loader = new Loader();

    // Create a DI
    $di = new FactoryDefault();

    $di->set('router',function() {
        require '../app/config/routes.php';
        return $router;

    // Setup the view component
    $di->set('view', function(){
        $view = new View();
        return $view;

    // Setup a base URI so that all generated URIs include the "tutorial" folder
    $di->set('url', function(){
        $url = new UrlProvider();
        return $url;

    // Handle the request
    $application = new Application($di);

    echo $application->handle()->getContent();

} catch(\Exception $e) {
     echo "PhalconException: ", $e->getMessage();


It looks ok. Can you paste your Apache/Nginx configuration for this host ? Also, You might want to use groups:

$router = new \Phalcon\Mvc\Router(false);

$noauth = new \Phalcon\Mvc\Router\Group([
    'controller' => 'noauth'


$noauth->addGet('', ['action' => 'home']);
$noauth->addGet('masses', ['action' => 'masses']);


return $router;

edited May '15


rewrite was not enabled. Thank you for your time and sorry for being dumb.

If anyone else has this problem, run:

sudo a2enmod rewrite

sudo service apache2 restart

...assuming you're on ubuntu/apache