Cakephp网址链接

I want to make all my pages/urls seo friendly including the dynamic ones but i'm stuck at it.

I made it work for the static pages for example :

$routes->connect('/:lang/about',['controller' => 'Pages', 'action' => 'about'] ); 

But when i add the following to routes

$routes->connect('/:lang/:slug',['controller' => 'MyController', 'action' => 'index'], ['pass' => ['slug']] ); 

All the pages redirect to MyController even the static ones, so i'm wondering if there is any solution to that one.

Thanks.

"catch-all" routes (like the one in your question) need to go after other routes. This way the static routes are checked first and "catch-all" are used only when no other routes were matched

For example:

$routes->connect('/:lang/about',['controller' => 'Pages', 'action' => 'about'] );
$routes->connect('/:lang/:slug',['controller' => 'MyController', 'action' => 'index'], ['pass' => ['slug']] );

Instead of (notice the ordering):

$routes->connect('/:lang/:slug',['controller' => 'MyController', 'action' => 'index'], ['pass' => ['slug']] );
$routes->connect('/:lang/about',['controller' => 'Pages', 'action' => 'about'] );