【问题标题】:How to rewrite domain in Zend Framework如何在 Zend Framework 中重写域
【发布时间】:2009-06-21 06:17:12
【问题描述】:

我正在编写用户注册表。
用户使用用户名注册后,例如“Billy”,我希望他使用 URL billy.mydomain.com 访问服务器。

billy.mydomain.com 的 Zend 框架链接是
www.mydomain.com/profile/index/username/billy

我想知道如何从
重写网址 www.mydomain.com/profile/index/username/billy

billy.mydomain.com

【问题讨论】:

    标签: zend-framework


    【解决方案1】:

    抛开我最初的回答,This Solution 更加优雅。

    $hostnameRoute = new Zend_Controller_Router_Route_Hostname(
        ':username.mydomain.com',
        array(
            'controller' => 'profile',
        )
    );
    
    $pathRoute = new Zend_Controller_Router_Route(":action/*", array( 'action'=>'index' ));
    $chain = $hostnameRoute->chain($pathRoute);
    
    // add $chain to your router
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-25
      • 2011-03-04
      • 1970-01-01
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多