Custom routes not working

Hello,

i have tried to create a simple custom route, but it is not working. I want to override /about into /ueber-uns. Phalcon version 3.0 and PHP 7.0.8

Controller: About Action: index

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

 $router->add('/ueber-uns', [
    'controller' => 'about_control',
    'action' => 'index'
 ]);

 return $router;

Rgds Stefan

I might be missing something in your query but this is what you have.

Controller : About

in your route you call controller "aboutControl"



29.2k

Hello Jed,

thank you for your reply, but nothing works right now. This is a simple link <a href="/about"> and i want to change the /about into /ueber-uns.

Do you have another idea?

Rgds Stefan

edited 10d ago

Can you change the code to the following and test

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

$router->add('/ueber-uns', [ 'controller' => 'about', 'action' => 'index' ]);

return $router;



29.2k

Hello Jed,

thx again, but it changes also nothing. I am using Vokuro, maybe it helps.

Rgds Stefan

Hello Unfortunately unless you can send me a link to your github repo or send me some kind of error I cant help you further.

edited 4d ago

So when a user visits /about, do you want to redirect them to /ueber-uns, or just have them see the output from ueberUnsController::index() with the url unchanged?



29.2k
edited 4d ago

Hello Dylan,

i have the AboutController::index() and i want to override the url from /about to /ueber-uns or to /blabla whatever i want. Because i want to implement mult-language in next steps EN, GER, FR ....

Is this possible?

Rgds Stefan

If you want to change the url, then you want a redirect, not a route: https://docs.phalconphp.com/en/3.3/response#redirections