Zend框架子域问题

发布于 2024-08-07 19:30:19 字数 1112 浏览 6 评论 0原文

我正在使用 .ini 文件在我的应用程序中添加路由。

resources.router.routes.username.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.username.route = ":username.example.com"
resources.router.routes.username.defaults.module = "userinfo"
resources.router.routes.username.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.username.chains.index.route = ":language/:controller/:action/*"
resources.router.routes.username.chains.index.defaults.controller = "index"
resources.router.routes.username.chains.index.defaults.action = "index"

1) http://john.example.com/fr/controller/action
2) http://john.example.com/fr/controller/action/id/10

#1 网址有效。此处请求参数

Request Parameters:
array (
  'language' => 'fr',
  'controller' => 'controller',
  'action' => 'action',
  'username' => 'john',
  'module' => 'userinfo',
)  

#2 url 不起作用。在这里请求参数

Request Parameters:
array (
  'controller' => 'fr',
  'action' => 'controller',
  'module' => 'default',
)  

任何人都可以为此建议一个解决方案。

I am using .ini file to add routes in my application.

resources.router.routes.username.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.username.route = ":username.example.com"
resources.router.routes.username.defaults.module = "userinfo"
resources.router.routes.username.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.username.chains.index.route = ":language/:controller/:action/*"
resources.router.routes.username.chains.index.defaults.controller = "index"
resources.router.routes.username.chains.index.defaults.action = "index"

1) http://john.example.com/fr/controller/action
2) http://john.example.com/fr/controller/action/id/10

#1 url it's work. Request parameter here

Request Parameters:
array (
  'language' => 'fr',
  'controller' => 'controller',
  'action' => 'action',
  'username' => 'john',
  'module' => 'userinfo',
)  

#2 url it's not work. Request parameter here

Request Parameters:
array (
  'controller' => 'fr',
  'action' => 'controller',
  'module' => 'default',
)  

Can anyone suggest a solution for this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

听闻余生 2024-08-14 19:30:19

您是否为路线设置了默认语言?说它不起作用你能提供更多细节吗?
我遇到了一些类似的问题,Zend_navigation 没有接受语言参数,并且总是切换到我定义的默认语言。

最终我必须通过在自定义插件的 routshutdown 中手动设置默认语言来破解它,如果有帮助请参阅我的帖子

Zend Framework:Zend_translate 和路由相关问题

did you set a default language for the route? by saying it doesn't work could you provide more details?
I ran into some similar problem with Zend_navigation not taking in the language param and always switch to the default lang that i defined.

Eventually i have to hack it by manually setting default language in the routshutdown in a custom plugin please see my post if it helps

Zend Framework: Zend_translate and routing related issue

月下客 2024-08-14 19:30:19
resources.router.routes.username.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.username.route = ":username.example.com"
resources.router.routes.username.defaults.module = "userinfo"
resources.router.routes.username.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.username.chains.index.route = ":language/:controller/:action/*"
resources.router.routes.username.chains.index.defaults.controller = "index"
resources.router.routes.username.chains.index.defaults.action = "index"
resources.router.routes.username.chains.index.defaults.language = "en"

我在路由中添加默认语言参数。但这个网址不起作用

http://john.example.com/fr/controller/action/id/10
Request Parameters:
array (
  'controller' => 'fr',
  'action' => 'controller',
  'module' => 'default',
)
resources.router.routes.username.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.username.route = ":username.example.com"
resources.router.routes.username.defaults.module = "userinfo"
resources.router.routes.username.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.username.chains.index.route = ":language/:controller/:action/*"
resources.router.routes.username.chains.index.defaults.controller = "index"
resources.router.routes.username.chains.index.defaults.action = "index"
resources.router.routes.username.chains.index.defaults.language = "en"

I add to default language parameter in route. But this url not work

http://john.example.com/fr/controller/action/id/10
Request Parameters:
array (
  'controller' => 'fr',
  'action' => 'controller',
  'module' => 'default',
)
£烟消云散 2024-08-14 19:30:19

看起来路线已重置为默认值。 之前遇到了这个问题

我在创建插件并注册到前端控制器 。在那里定义dispatchLoopStartup(),尝试设置语言参数或模块名称,

$router = $fc->getRouter();
$router->setGlobalParam('lang','somelanguage');
$router->setGlobalParam('module','somemodule');

看看是否可以带回正确的路由。

Looks like the route has been reset to default. I run into that before

create a plugin and register to the front controller. Define dispatchLoopStartup() in there try set the language parameter or module name using

$router = $fc->getRouter();
$router->setGlobalParam('lang','somelanguage');
$router->setGlobalParam('module','somemodule');

see if you can bring back the correct route.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文