Reputation: 3164
I have this route:
Router::connect(
'/:controller/*',
array('controller'=>'con3'),
array('controller'=>'con1|con2')
);
I am trying to direct every call to
/con1/x1/x2
to
/con3/x1/x2
and
/con2/y1/y2
to
/con3/y1/y2
it is not working, why ?
Upvotes: 0
Views: 129
Reputation: 2313
If you require to route /con3/
to /con1/
and/or /con2/
based on your own constraints what you require is a Custom Route class
. For this there is no better place than Mark Story's tutorial on custom Route
classes.
Otherwise, you could of course just extend your controllers (and leave the body empty) like this:
<?php
class Con3Controller extends Con1Controller{
// maybe add model here if you don't have
// var $uses in Con1Controller
// otherwise, extend is just fine
}
?>
In this case you don't need to mess with connecting routes like you are right now. Object inheritance will take care of your "aliasing" for you.
Upvotes: 1
Reputation: 2483
Have you considered something like:
Router::connect( '/con1/:action/*', array( 'controller' => 'con3' ) );
Router::connect( '/con2/:action/*', array( 'controller' => 'con3' ) );
Upvotes: 1