I have named route for those users who forgot theirs passwords,
<?php
$router->add(
"/forgot-password",
array(
'module' => 'frontend',
'controller' => "session",
'action' => 'forgotPassword'
)
);
It's work just fine whe I use URL like this
https://my-site-name.com/forgot-password
But this URL does the same thing
https://my-site-name.com/session/forgotPassword
I suppose that all of my named routes have their clone with canonnical url
https://my-site-name.com/:controller/:action
I realize that it's becasue I setted up some common routes in case when I do not have named route.
<?php
$router = new \Phalcon\Mvc\Router(false);
$router->add(
"/",
array(
'module' => 'frontend',
'controller' => "index",
'action' => 'index'
)
)->setName("homepage");
$router->add(
"/:controller",
array(
'module' => 'frontend',
"controller" => 1,
"action" => "index"
)
);
$router->add(
"/:controller/:action",
array(
'module' => 'frontend',
"controller" => 1,
"action" => 2
)
);
$router->add(
"/:controller/:action/:params",
array(
'module' => 'frontend',
"controller" => 1,
"action" => 2,
"params" => 3,
)
);
$router->add(
"/login",
array(
'module' => 'frontend',
'controller' => "session",
'action' => 'login'
)
);
$router->add(
"/restore-password",
array(
'module' => 'frontend',
'controller' => "session",
'action' => 'forgotPassword'
)
);
$router->add(
"/sign-up",
array(
'module' => 'frontend',
'controller' => "session",
'action' => 'signup'
)
);
$router->add(
"/logout",
array(
'module' => 'frontend',
'controller' => "session",
'action' => 'logout'
)
);
$router->add(
"/forgot-password",
array(
'module' => 'frontend',
'controller' => "session",
'action' => 'forgotPassword'
)
);
$router->add(
"/callback",
array(
'module' => 'frontend',
'controller' => "session",
'action' => 'callback'
)
);
$router->add("/admin/:controller/:action/:params", array(
'module' => 'backend',
'controller' => 1,
'action' => 2,
"params" => 3,
));
$router->add("/admin/:controller/:action", array(
'module' => 'backend',
'controller' => 1,
'action' => 2,
));
$router->add(
"/admin/:controller",
array(
'module' => 'backend',
"controller" => 1,
"action" => "index"
)
);
$router->add(
"/admin",
array(
'module' => 'backend',
'controller' => "index",
'action' => 'index'
)
);
$router->removeExtraSlashes(true);
return $router;
So my question is easy. How can I prevent application use common route (ex. /session/forgotPassword) and use the named route (ex. /forgot-password) in case when named route is exist in route's definition.
Thanks.