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

Use Colon as seperator in url

Hi

I want to use site/post:110 instead of normal routing: site/post/110

how I can do that?

I also added a routing but not working:

          $router->add('/post(:)([0-9])', array(
            'module' => 'backend',
            'controller' => 'posts',
            'action' => 'show',
            'id' => 2
        ));


98.9k
Accepted
answer

This way:

$router->add('/post:([0-9]+)', array(
    'module' => 'backend',
    'controller' => 'posts',
    'action' => 'show',
    'id' => 1
));