Reputation: 2215
I currently have a CakePHP route setup from: Variable Prefixed Routing in CakePHP
Here's my routes.php:
Router::connect( "/:forum/:controller/:action/*", array(), array("pass" => array("forum")) ); Router::connect( "/:forum", array( "controller" => "forums", "action" => "index" ), array("pass" => array("forum")) );
This works perfectly, for example /example/users/login
will be routed to UsersController::login, and $this->request->params["forum"]
will contain example
.
However, upon looking at tmp/logs/debug.log
I see that there are a lot of errors produced by this route, and I can't understand why this happens because the routing apparently works perfectly:
2012-08-22 02:29:09 Error: [MissingControllerException] Controller class ExampleController could not be found. #0 /var/www/app/webroot/index.php(92): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse)) #1 {main}
It essentially is attempting to look for a ExampleController (because I am trying to access /example/users/login
), but routes.php
specifically tells CakePHP to look for Users controller as opposed to Example Controller.
Is there a way to fix this issue? I cannot understand why it happens since everything apparently works correctly.
Upvotes: 1
Views: 4963
Reputation: 6767
Does /example/users work, as in does it route to UsersController::index(). If not, you should need a route for just /:forum/:controller so try adding this before your current routes and see if it clears up the errors:
Router::connect(
"/:forum/:controller",
array('action' => 'index'),
array("pass" => array("forum"))
);
Upvotes: 1