CAKEPHP中的URL重定向与数据库值

时间:2017-07-10 04:10:49

标签: php cakephp url-redirection

我正在开发一个基于cakephp的项目。我只想知道如何制作完美的URL重定向表格数据库值。 例如 我在这里给出了两个当前的URL和所需的URL

1.Current

/search?vendor=combo-training-certification-courses

1.Desired

combo-training-certification-courses

2.Current

/search?vendor=pmi-training-certification-courses

2.Desired

/pmi-training-certification-courses

请告诉我如何实现它......

1 个答案:

答案 0 :(得分:1)

只需在config / routes.php

中添加以下代码即可
App::uses('ClassRegistry', 'Utility');
$Route = ClassRegistry::init('Vendor'); //MODEL NAME You can change it as your needs.
$routes = $Route->find('all');
foreach ($routes as $route) {
    Router::connect('/', array('controller' => $route['Route']['controller'], 'action' => $route['Route']['action']));
}

Reference