开发者

cakePHP - how to ovveride the default routing?

开发者 https://www.devze.com 2023-04-03 19:04 出处:网络
I have a controller, and I have several aliases for a single function in it. eg: Router::connect( \'/controllerX/:method\',

I have a controller, and I have several aliases for a single function in it. eg:

Router::connect(
   '/controllerX/:method', 
   array('controller' => 'controllerX', 'action' => 'bigApple'),
   array('method'=>'help|ask|read', pass => array(method))
 );

Now, for some reason(don't ask..) I want to keep the original methods in the controller, but I don't want them to be available for direct access. Meaning: in the controller there will be functions named: ask,help, and read, but they won't be accessible for direct call.

if someone will enter the url /controllerX/ask, or /controllerX/help, i want him to be routed to somewhere else.

is it possib开发者_如何学运维le at all? (it seems like an endless loop..)


I think in your case, you have to do a check before and redirect to Controller:: setAction

Checkout: http://api.cakephp.org/class/controller#method-ControllersetAction

0

精彩评论

暂无评论...
验证码 换一张
取 消