如何将此路由重写为ini格式?

时间:2010-12-22 19:09:45

标签: zend-framework ini zend-controller-router

我有以下PHP代码:

$hostnameRoute = new Zend_Controller_Router_Route_Hostname(
            'subdomain.example.com',
            array(
                'module' => 'subdomain',
                'controller' => 'index',
                'action'     => 'index'
            )
        );

        $plainPathRoute = new Zend_Controller_Router_Route(
            ':controller/:action/*',
            array(
                'controller'=> 'index',
                'action' => 'index'   
            )
        );

        $router->addRoute('subdomain', $hostnameRoute->chain($plainPathRoute));

现在我想在我的application.ini

中使用这条路线

我尝试使用此代码,但这不起作用:

resources.router.routes.subdomain.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.subdomain.route = "subdomain.example.com"
resources.router.routes.subdomain.defaults.module = "subdomain"
resources.router.routes.subdomain.chains.default.route = ":controller/:action/*"
resources.router.routes.subdomain.chains.default.defaults.controller = "index"
resources.router.routes.subdomain.chains.default.defaults.controller = "index"

有人知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

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

试试这个