从2.1.4开始,不推荐使用Query路由,我将这样路由到我的博客:
'cro-blog' => array( 'type' => 'Literal', 'options' => array( 'route' => '/blog', 'defaults' => array( 'controller' => 'CroBlog\BlogController', 'action' => 'index', ), ), ),并链接到像/blog?p=x这样的页面/blog?p=x其中x是页码。 在我添加子路由之前,这非常有效。 链接到/blog仍然有效,但链接到页面会产生404(更具体的'请求的URL无法通过路由匹配'。)。 这是我目前的设置:
'cro-blog' => array( 'type' => 'Literal', 'options' => array( 'route' => '/blog', 'defaults' => array( 'controller' => 'CroBlog\BlogController', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'post' => array( 'type' => 'Segment', 'options' => array( 'route' => '/:slug', 'constraints' => array( 'slug' => '[a-zA-Z][a-zA-Z0-9_-]*', ), 'defaults' => array( 'action' => 'post', ), ), ), ), ),我正在使用Segment子路由,但Literal子路由存在同样的问题。
有什么方法可以保持页面查询和子路由?
Since 2.1.4 the Query route is deprecated, I'm routing to my blog like this:
'cro-blog' => array( 'type' => 'Literal', 'options' => array( 'route' => '/blog', 'defaults' => array( 'controller' => 'CroBlog\BlogController', 'action' => 'index', ), ), ),And link to pages like /blog?p=x where x is the page number. This works perfectly until I add a child route. Linking to /blog still works but linking to pages give a 404 (more specific 'The requested URL could not be matched by routing.'). This is my current setup:
'cro-blog' => array( 'type' => 'Literal', 'options' => array( 'route' => '/blog', 'defaults' => array( 'controller' => 'CroBlog\BlogController', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'post' => array( 'type' => 'Segment', 'options' => array( 'route' => '/:slug', 'constraints' => array( 'slug' => '[a-zA-Z][a-zA-Z0-9_-]*', ), 'defaults' => array( 'action' => 'post', ), ), ), ), ),I'm using a Segment child route but the same problem exists with a Literal child route.
Any way to keep the page query and the child routes?
最满意答案
这解决了。 如果有人遇到同样的问题,这对我有用。
清除所有缓存(EdpSuperluminal,APC等) 删除Zend库 在没有Zend库的情况下运行你的应用程序(当然会给出很多错误,但这对我来说似乎至关重要) 重新安装Zend库 再次运行您的应用程序我安装了2.1.5dev并解决了这个问题。 想要确定它是否是一个错误,所以再次尝试2.1.4并且问题仍然是固定的。 所以这是我的结论。 缓存可能是一件奇怪的事情。
编辑过早地跳到(错误的)结论。 解雇了Zend Studio 10,现在再次出现问题。 我认为Zend Studio 10正在恢复一些文件(并不是所有文件,因为查询路由确实被标记为已弃用)。 不过,考虑到这个解决了,只需找到一种方法告诉Zend Studio 10使用2.1.4。 谢谢!
This is solved. If anyone experiences the same issues, this is what worked for me.
Clear all cache (EdpSuperluminal, APC etc.) Remove Zend library Run your application without Zend library (giving loads of errors of course, but this seemed crucial to me to make it work) Re-install Zend library Run your application againI installed 2.1.5dev and it fixed the issue. Wanted to make sure whether it was a bug or not so tried again with 2.1.4 and the issue was still fixed. So this is my conclusion. Cache can be a weird thing.
Edit Jumped to (the wrong) conclusions too soon. Fired up Zend Studio 10 and now it bugs again. I think Zend Studio 10 is reverting some files (not all since Query route did got marked as deprecated). Still, consider this solved, just need to find a way to tell Zend Studio 10 to use 2.1.4. Thanks!
更多推荐
发布评论