我正在开发一个基于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
请告诉我如何实现它......
答案 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']));
}