Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/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
Routing Cakephp路由到同一控制器_Routing_Routes_Cakephp 1.3 - Fatal编程技术网

Routing Cakephp路由到同一控制器

Routing Cakephp路由到同一控制器,routing,routes,cakephp-1.3,Routing,Routes,Cakephp 1.3,我想让它像: www.xxx.com/product1 使用订单控制器的index()并将product1作为参数传递 www.xxx.com/product2 使用订单控制器的index()并将product2作为参数传递 那么 www.xxx.com/product1/shipping 使用订单控制器的发货() www.xxx.com/product2/shipping 使用订单控制器的发货() 我试过: Router::connect('/:product', array('contro

我想让它像:

www.xxx.com/product1
使用订单控制器的index()并将product1作为参数传递

www.xxx.com/product2
使用订单控制器的index()并将product2作为参数传递

那么

www.xxx.com/product1/shipping
使用订单控制器的发货()

www.xxx.com/product2/shipping
使用订单控制器的发货()

我试过:

Router::connect('/:product', 
array('controller' => 'order'),
array(
        'product' => 'product1|product2',
        'pass' => array('product')
)
);
它适用于
www.xxx.com/product2

我尝试了
/:product/:action
使它在
index()之后工作,但没有成功。它显示产品1的
缺少控制器
或其他内容


我该怎么办?

一般来说,我建议使用某种分母,比如
hostname.tld/products/product1
或更短的
host.tld/p/product1
。这将使您在将来更容易扩展此功能。您可能想了解一下REST或Restful URL的概念

然而,如果你想坚持这个计划,你应该尝试用Apache重写你的URL,这对用户来说会更快,更容易跟踪自己,更灵活,因为你可以编写各种模式,包括正则表达式