Zend framework Zend Route XML配置未按预期工作
下面是我的routes.xml,它被加载到我的Zend Framework应用程序中。有两条路线,一条应该匹配urlZend framework Zend Route XML配置未按预期工作,zend-framework,zend-route,Zend Framework,Zend Route,下面是我的routes.xml,它被加载到我的Zend Framework应用程序中。有两条路线,一条应该匹配url/aanbod/tekoop/huis,另一条应该匹配/aanbod/200/gerenoveerde woning 问题是,这两个示例URL都以detail操作结束,而第一个示例URL应该以index操作结束 有人能澄清这个路由设置的错误吗 <routes> <property_overview type="Zend_Controller_Router
/aanbod/tekoop/huis
,另一条应该匹配/aanbod/200/gerenoveerde woning
问题是,这两个示例URL都以detail操作结束,而第一个示例URL应该以index操作结束
有人能澄清这个路由设置的错误吗
<routes>
<property_overview type="Zend_Controller_Router_Route">
<route>/aanbod/:category/:type</route>
<reqs category="(tekoop|tehuur)" />
<reqs type="[A-Za-z0-9]+" />
<defaults module="frontend" controller="property" action="index" />
</property_overview>
<property_detail type="Zend_Controller_Router_Route">
<route>/aanbod/:propertyid/:slug</route>
<reqs propertyid="[0-9]+" />
<reqs slug="(^\s)+" />
<defaults module="frontend" controller="property" action="detail" />
</property_detail>
</routes>
/aanbod/:category/:type
/aanbod/:propertyid/:slug
我认为您不能使用reqs
参数来帮助识别Zend\u控制器\u路由器\u路由
。在您的情况下,您的路由是相同的,因为路由堆栈是后进先出的,所以“细节”优先
也许可以试着改用
我很难找到regex路由器的配置方法,但在代码中它看起来像
$route = new Zend_Controller_Router_Route_Regex(
'aanbod/(tekoop|tehuur)/([A-Za-z0-9]+)',
array('controller' => 'property', 'action' => 'index', 'module' => 'frontend'),
array(1 => 'category', 2 => 'type')
);
$route = new Zend_Controller_Router_Route_Regex(
'aanbod/(\d+)/(\S+)',
array('controller' => 'property', 'action' => 'detail', 'module' => 'frontend'),
array(1 => 'propertyid', 2 => 'slug')
);
我认为您不能使用
reqs
参数来帮助识别Zend\u Controller\u Router\u route
的路由。在您的情况下,您的路由是相同的,因为路由堆栈是后进先出的,所以“细节”优先
也许可以试着改用
我很难找到regex路由器的配置方法,但在代码中它看起来像
$route = new Zend_Controller_Router_Route_Regex(
'aanbod/(tekoop|tehuur)/([A-Za-z0-9]+)',
array('controller' => 'property', 'action' => 'index', 'module' => 'frontend'),
array(1 => 'category', 2 => 'type')
);
$route = new Zend_Controller_Router_Route_Regex(
'aanbod/(\d+)/(\S+)',
array('controller' => 'property', 'action' => 'detail', 'module' => 'frontend'),
array(1 => 'propertyid', 2 => 'slug')
);
请尝试以下方法:
<routes>
<property_overview type="Zend_Controller_Router_Route">
<route>aanbod/:category/:type</route>
<reqs category="(tekoop|tehuur)" type="[A-Za-z0-9]+" />
<defaults module="frontend" controller="property" action="index" />
</property_overview>
<property_detail type="Zend_Controller_Router_Route">
<route>aanbod/:propertyid/:slug</route>
<reqs propertyid="[0-9]+" slug="[^\s]+" />
<defaults module="frontend" controller="property" action="detail" />
</property_detail>
</routes>
aanbod/:category/:type
aanbod/:propertyid/:slug
我改变了什么:
- 您应该只有一个“reqs”元素-将不同的需求添加为该元素的属性。这是您的路线不起作用的主要原因,因为每个路线中只使用了一个REQ
- 删除初始斜杠-这没有任何作用
- 将slug模式更改为
,意思是“空格以外的任何字符,一次或多次”,我想这就是您的意思[^\s]+
<routes>
<property_overview type="Zend_Controller_Router_Route">
<route>aanbod/:category/:type</route>
<reqs category="(tekoop|tehuur)" type="[A-Za-z0-9]+" />
<defaults module="frontend" controller="property" action="index" />
</property_overview>
<property_detail type="Zend_Controller_Router_Route">
<route>aanbod/:propertyid/:slug</route>
<reqs propertyid="[0-9]+" slug="[^\s]+" />
<defaults module="frontend" controller="property" action="detail" />
</property_detail>
</routes>
aanbod/:category/:type
aanbod/:propertyid/:slug
我改变了什么:
- 您应该只有一个“reqs”元素-将不同的需求添加为该元素的属性。这是您的路线不起作用的主要原因,因为每个路线中只使用了一个REQ
- 删除初始斜杠-这没有任何作用
- 将slug模式更改为
,意思是“空格以外的任何字符,一次或多次”,我想这就是您的意思[^\s]+