Is it possible to have pages route without the controller in the URL but still have other controllers work? Example:
- Access pages like this: http://domain.com/about/
- Instead of like this: http://domain.com/pages/about/
- But still have access to http://domain.com/othercontroller/action/
Doing the following works for having the pages without /pages/ in the URL but if I try to access any other controller it doesn't work:
- From:
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
- To:
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'index'));
Is there a way to setup the Router so that it runs controller/action if it exists. If it does not it runs the pages controller/action?
Router::connect('/:pagename', array('controller' => 'Pages', 'action' => 'display'));
and in display action you grab the parameter like this$pagename = $this->params->pagename;
the other url (domain.com/users/edit/1) would remain unaffected because it has extra bits that arent covered in just defined route (/edit/1) this way you dont have to enumerate page names as long as you dont have conflicting url matches. – user2074884