CakePHP 3 Routing: How to route controller basis

523 views Asked by At

I am using cakephp 3. I want to hide frontends controller in url.

My Routes config:

Router::connect('/:action', array('controller' => 'frontends'));

And I want to refer all function to bloggers controller when url start as www.example.com/bloggers

Router::connect('/bloggers/:action', array('controller' => 'bloggers'));

But www.example.com/bloggers also refers to frontends Controller's index function. It should refer to bloggers Controller's index function. Any help?

1

There are 1 answers

0
Pradeep Singh On BEST ANSWER

Just change the order of your routing

First write this

Router::connect('/bloggers/:action', array('controller' => 'bloggers'));

and then this one

Router::connect('/:action', array('controller' => 'frontends'));