PHP Zend Route Config.ini - similar patterns(PHP Zend Route Config.ini - 类似模式)
问题描述
我正在使用配置文件在我的应用程序中路由我的请求.我有以下条目:
I'm using a configuration file to route my requests in my application. I have the following entries:
routes.deal.route = "deal/:id/*"
routes.deal.route = "deal/:id/*"
routes.deal.defaults.controller = "deal"
routes.deal.defaults.controller = "deal"
routes.deal.defaults.action = "index"
routes.deal.defaults.action = "index"
routes.deal.reqs.id = "d+"
routes.deal.reqs.id = "d+"
routes.deal.route = "deal/buy/:id/*"
routes.deal.route = "deal/buy/:id/*"
routes.deal.defaults.controller = "deal"
routes.deal.defaults.controller = "deal"
routes.deal.defaults.action = "购买"
routes.deal.defaults.action = "buy"
routes.deal.reqs.id = "d+"
routes.deal.reqs.id = "d+"
这是我正在寻找的行为:mysite.com/deal/75 --- 这将显示 Deal 75 的详细信息(相当于 mysite.com/deal/?id=75; controller=deal, action=index)
here's what the behavior I'm looking for: mysite.com/deal/75 --- this will display the details of Deal 75 (equivalent to mysite.com/deal/?id=75; controller=deal, action=index)
mysite.com/deal/buy/75 -- 购买交易 75 或 (controller=deal, action=buy) -- 相当于 mysite.com/deal/buy?id=75
mysite.com/deal/buy/75 -- buy deal 75 or (controller=deal, action=buy) -- equivalent to mysite.com/deal/buy?id=75
我只能让一个工作,而另一个不能.无论在配置中首先指定哪个,这都是有效的.
I can only get one to work and not the other. Whichever is specified first in the config, that's what will work.
谁能指出我在这里做错了什么?非常感谢任何帮助.
Can anyone point out what I'm doing wrong here? Any help is greatly appreciated.
谢谢,王子
推荐答案
尝试更改第二条路线的名称,即:
Try changing the name of the second route, i.e:
routes.dealbuy.route = "deal/buy/:id/*"
routes.dealbuy.defaults.controller = "deal"
routes.dealbuy.defaults.action = "buy"
routes.dealbuy.reqs.id = "d+"
路由需要有不同的名称.
The routes need to have different names.
这篇关于PHP Zend Route Config.ini - 类似模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP Zend Route Config.ini - 类似模式


基础教程推荐
- PHP 守护进程/worker 环境 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01