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

Routing problem - see index everyway

Hi guys!

I created routing at:

    $di->set('router', function () {

        //return require_once 'app/config/routes.php';
        $router = new Phalcon\Mvc\Router(false);

    // Игнорим слеш в конце
    $router->removeExtraSlashes(true);

    $router->notFound(array(
        'controller' => 'index',
        'action' => '_404'
    ));

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

    $router->add('/geo', array(
        'controller' => 'geo',
        'action'     => 'detect',
    ));

    $router->add('/battle', array(
        'controller' => 'battle',
        'action'     => 'view',
    ));

    return $router;

    });

what i doing wrong? every way i see index controller and index action :(



85.5k

multi / signle module app ?

edited Oct '15

single



85.5k

can you try by removing the false here

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

:( no, it solution not helped

may be i have bad dirs structure in view ?



85.5k
Accepted
answer
edited Oct '15

.htaccess stuff is all set up ?

  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]

i use nginx, Thanks for the tip!!

location /{
    autoindex off;
    index index.php index.html;
    if (!-e $request_filename) {
        #rewrite ^(.*)$ /index.php;
        rewrite ^(.*)$ /index.php?_url=$1;
    }
    }

I forgot to add _url=$1 )

thanks!