My problem is about routing in Zend Framework 2. In my ZF2 application, older router was like route => '/app/[:/someParams]'. Now, I'm trying to make dynamic for my site for example about-us. I'm using unique slug name for dynamic pages. Every thing works fine. But when that url becomes like /application then it identifies as a first route. So, route conflicts are happening.

有帮助吗?

解决方案

Try with priority if conflicts happen

priority with high rank is the highest priority for the router to check the right route.

return array(
    'router' => array(
        'routes' => array(
            'admin' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'priority' => 100,             // <----
                'options' => array(
                    'route'    => '/admin',
                    'defaults' => array(
                        'controller' => 'Admin\Controller\Admin',
                        'action'     => 'index',
                    ),
                ),
             ),
         ),
      ),
   ),

about the route you describe, use Segment to define some parameters (:/SomeParams)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top