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

short url service

Hello! I have a task cut url for example:

https://site.ru/page/?utm_source=1&utm_medium=2&utm_campaign=3&utm_content=4&utm_term=5

on the:

https://site.ru/r_Hyft64Kl

I have a router file:

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

$router->add(
 '/r_([A-Za-z0-9] {8})',
[
 'controller' => 'index',
'action'     => 'index',
 'alias' => 1
]
);

return $router;

I get the error:

RHyft64KlController handler class cannot be loaded

Very good it would be to get a link without prefix "r_"

https://site.ru/Hyft64Kl

How do I configure the router?

well your kind of doing it wrong, its trying to locate the controller based on the url so try:

router file :



$router->add("/r_{shorturl:[a-zA-Z0-9\_\-]+}", [
  "namespace"  => "Api\Controllers", //  what ever you have named your namespace
  "module"     => "Api", // module of that app , not necessary but good to specify
  'controller' => 'index',
  'action'     => 'index'
]);