我需要创建一个自定义网址,例如http://example.com/type_of_institution/institutin_name
我在/routes.php中添加了以下几行
$routes->connect(
'/:type/:name',
['controller' => 'Institutions', 'action' => 'view'],
['type' => '[a-z_]+', 'name' => '[a-z_]+', 'pass' => ['type','name']]
);
//in my controller
public function view($type,$name){
this->autoRender = false;
}
我已尝试使用http://example.com/private_institution/test_institution,但我收到以下错误:
Error: [Cake\Routing\Exception\MissingControllerException] Controller class PrivateInstitution could not be found.
我改成
之后$routes->connect(
'institutions/:type/:name',
['controller' => 'Institutions', 'action' => 'view'],
['type' => '[a-z_]+', 'name' => '[a-z_]+', 'pass' => ['type','name']]
);
与http://example.com/institutions/private_institution/test_institution
合作在Cakephp 3中,只有params制作一个url?(第一个例子)