2008年12月8日星期一

Re: [fw-core] Hostname routing query

Hi,
 
I still don't understand this, sorry
 
I have a routes config file which provides an array to the addConfig method of the router like...
$router->addConfig(new Zend_Config($routes));
 
The route config file looks like...
return array(
//...
'static_path' => array(
        'type'  => 'Zend_Controller_Router_Route_Regex',
        'route' => 'pages(\/.+)?',
        'defaults' => array(
            'controller'      => 'static',
            'action'          => 'view'
        ),
        'map' => array(
            1                 => 'file'
        ),
        'reverse'              => 'pages/%s'
    ),
//...
}
 
Can you please help me modify the above route to enable routing like...
 
Where...
$file = '' or 
$file = 'about' or
$file = '/help/about-someting' etc.
 
Thanks again.
-R
 
On 12/8/08, keith Pope <mute.pop3@googlemail.com> wrote:
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]
----------------------------------------------------------------------

没有评论: