1

我正在使用 Zend 1.9 并希望将语言参数作为子域。

喜欢:http ://en.site.com

是否可以在 .htaccess 中获取语言并将其设置为我可以在 Zend 中使用的环境变量?

实现我想要的最好方法是什么?

- 添加 - :

我将此添加到我的 routes.ini 中:

[routes]

routes.lif.type = "Zend_Controller_Router_Route_Hostname"
routes.lif.route = ":language.domain.:tld"
routes.lif.reqs.language= "[a-z]{2}"
routes.lif.defaults.controller = "index"
routes.lif.defaults.action = "index"
routes.lif.defaults.language = "en"

; default
routes.lif.chains.default.type = "Zend_Controller_Router_Route"
routes.lif.chains.default.route = "/:controller/:action"
routes.lif.chains.default.defaults.controller = index
routes.lif.chains.default.defaults.action = index

; register
routes.lif.chains.register.type = "Zend_Controller_Router_Route"
routes.lif.chains.register.route = "/register"
routes.lif.chains.register.defaults.controller = "register"
routes.lif.chains.register.defaults.action = "newuser"

; details
routes.lif.chains.band.type = "Zend_Controller_Router_Route"
routes.lif.chains.band.route = "/details/:name"
routes.lif.chains.band.defaults.controller = "details"
routes.lif.chains.band.defaults.action = "getdetails"

如果我去:http ://en.domain.com/details/joe,这很好用 但不幸的是,如果我删除子域:http ://domain.com/details/joe默认操作不会被调用,我得到

消息:动作“joe”不存在并且没有被困在 __call()

你有想法吗 ?

多谢你们。

蒂埃里

4

1 回答 1

2

You're in luck - there's a Zend_Controller_Router_Route_Hostname which can be used instead for exactly this purpose. If you want to achieve custom routing in the part after your domain, you'll need to take a look at Zend_Controller_Router_Route_Chain.

于 2009-10-24T23:32:31.283 回答