Url zend框架路由1.11
我似乎找不到简单的工作路线 我想要这个网址: example.com/restaurant/1/a-restaurant-name.html 改顶 example.com/restaurant?id=1*name=a-restaurant-name 我有下面的路线,但它不起作用,我得到的只是重定向到我的404页面Url zend框架路由1.11,url,zend-framework,routing,router,Url,Zend Framework,Routing,Router,我似乎找不到简单的工作路线 我想要这个网址: example.com/restaurant/1/a-restaurant-name.html 改顶 example.com/restaurant?id=1*name=a-restaurant-name 我有下面的路线,但它不起作用,我得到的只是重定向到我的404页面 $rest_friendly = new Zend_Controller_Router_Route( "/restaurant/:id/:name", arra
$rest_friendly = new Zend_Controller_Router_Route(
"/restaurant/:id/:name",
array(
"module" => "default",
"controller" => "restaurant",
"action" => "index"
)
);
我已将其加载到一个名为Route的预发布Frontcontroller插件中
插件100%加载,因为骰子(“加载”)总是会触发
另外,我也不知道如何调试它。
preDispatch()
是在路由完成后调用的,这就是为什么您所拥有的不起作用的原因。就像prodigitalson在评论中建议的那样,您应该在引导程序中添加路由。IIRC您应该在引导程序中这样做,而不是作为响应事件的FC插件。要回答其他问题,请将路由中的:id
更改为restid
,然后删除“restid”=>“:id”
。然后在控制器中,您可以使用$this->getRequest()->getParam('restid')
Oops访问URL值-将路由中的:id
更改为:restid
,这就是我的意思。