Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CakePHP为控制器创建URL路由规则_Url_Cakephp_Routing - Fatal编程技术网

CakePHP为控制器创建URL路由规则

CakePHP为控制器创建URL路由规则,url,cakephp,routing,Url,Cakephp,Routing,我已经创建了一个控制器“业务”和操作方法调用“show_details” 当前url将是http://127.0.0.1:8080/caketest/businesses/show_details/1/Hattion_National_Bank_Plc 但是我需要将Url显示为http://127.0.0.1:8080/caketest/Hattion_National_Bank_Plc 我怎么能这样做?routes.php中的URL路由规则是什么 我是cakePHP新手,所以我尝试过这样做,但

我已经创建了一个控制器“业务”和操作方法调用“show_details”

当前url将是
http://127.0.0.1:8080/caketest/businesses/show_details/1/Hattion_National_Bank_Plc

但是我需要将Url显示为
http://127.0.0.1:8080/caketest/Hattion_National_Bank_Plc
我怎么能这样做?routes.php中的URL路由规则是什么


我是cakePHP新手,所以我尝试过这样做,但失败了。非常感谢您的帮助。

将此添加到您的
配置/routes.php
中,然后尝试点击不带方法名的url

Router::connect('/businesses/*', array('controller' => 'businesses', 'action' => 'show_details'));

检查此链接-()第二个url中没有id,它不仅仅是路由定义。路线必须是/*以匹配问题中的示例
Router::connect('/businesses/*', array('controller' => 'businesses', 'action' => 'show_details'));