Cakephp url链接

Cakephp url链接,php,cakephp,Php,Cakephp,我想让我所有的网页/网址seo友好,包括动态的,但我被卡住了 我使其适用于静态页面,例如: $routes->connect('/:lang/about',['controller' => 'Pages', 'action' => 'about'] ); 但当我将以下内容添加到路由时 $routes->connect('/:lang/:slug',['controller' => 'MyController', 'action' => 'index'],

我想让我所有的网页/网址seo友好,包括动态的,但我被卡住了

我使其适用于静态页面,例如:

$routes->connect('/:lang/about',['controller' => 'Pages', 'action' => 'about'] ); 
但当我将以下内容添加到路由时

$routes->connect('/:lang/:slug',['controller' => 'MyController', 'action' => 'index'], ['pass' => ['slug']] ); 
所有页面都重定向到MyController,即使是静态页面,所以我想知道是否有解决方案


谢谢。

抓住所有像你问题中的路线一样的路线,然后再去其他路线。这样,首先检查静态路由,并且仅当没有匹配其他路由时才使用catch all

例如:

不要注意订购:

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

你需要这样的东西:$routes->connect'/:lang/posts/:slug'..@madalinivascu我不想添加任何静态的东西..静态是什么意思?控制器帖子的名称我不想,为什么你不想?什么阻止了你?
$routes->connect('/:lang/:slug',['controller' => 'MyController', 'action' => 'index'], ['pass' => ['slug']] );
$routes->connect('/:lang/about',['controller' => 'Pages', 'action' => 'about'] );