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

Custom extension in url

Dear All,

I did not find any information on how to create custom extension url ini phalcon ?

for example :

https://ebmt.wm/api/PenerimaManfaatIndividu automatically translated to https://ebmt.wm/api/PenerimaManfaatIndividu.json

i'm newbie in mod_rewrite

Thank you for your help.

Kind Regards, Wildan

You could use Phalcons custom routes - https://docs.phalcon.io/en/latest/reference/routing.html#usage-examples

https://example.com/api/Something to https://example.com/api/Something.json

$router->add("/api/:controller\.json", array(
    'module'      => 'api',
    'controller'  => 1,
    'file'        => 2
));

Thanks, it works!