2008年12月8日星期一

Re: [fw-core] Hostname routing query

You need to use the hostname route plus route chaining.

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

$route = new Zend_Controller_Router_Route_Hostname(
':username.domain.com',
array(
'controller' => 'account',
'action' => 'index'
),
array(
'username' => '(?!.*www)[a-zA-Z-_0-9]+'
)
);
$router->addRoute('account', $route->chain($actionRoute));

Hope this helps.

2008/12/8 Raavi Raaj <raaviraaj77@gmail.com>:
> Hi,
>
> Currently I have a route for static pages (e.g. about, terms, privacy, ...)
> like...
>
> 'static_path' => array(
> 'type' => 'Zend_Controller_Router_Route_Regex',
> 'route' => 'pages(\/.+)?',
> 'defaults' => array(
> 'controller' => 'static',
> 'action' => 'view'
> ),
> 'map' => array(
> 1 => 'file'
> ),
> 'reverse' => 'pages/%s'
> ),
>
> Which handles routes like...
> domain.com/pages/about
> domain.com/pages/help/someting
> etc.
>
> How can I use the hostname routing to achieve...
> pages.domain.com/about
> pages.domain.com/help/something
>
> All help is appreciated.
> -R
>
> P.S. I tried to achieve it by reading the documentation but came up with no
> working solution :)
>
>

--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------

没有评论: