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

Router ignores baseurl

My router seems to ignore the base url set in the url service and sets 'phal' as controller in for instance https://server.com/phal/index/index. Why is that? My service loader:

$di->set('url', function () use ($config) {
    $url = new UrlResolver();
    $url->setBaseUri('/phal/');

    return $url;
}, true);

//Registering a router
$di->set('router', function(){
    $router = new Router();

    $router->setDefaultModule("frontend");
    $router->add('/:controller/:action/:params', array(
        'module' => 'frontend',
        'controller' => 1,
        'action' => 2,
        'params' => 3
    ));

    $router->removeExtraSlashes(true);
    return $router;
});

The code worked on windows with xampp bot I can not make it run on debian nginx



85.5k

maybe location configuration problem ?

can you post the nginx config please



4.9k
Accepted
answer

I fixed the error by remoing /phal from url passed by nginx