Zend_Controller_Router_Route issue
I need to trim the first part of my url
Example /param1/12234/module/controller/action
would be开发者_JAVA技巧come /module/controller/action/param1/12234
I tried with
$router->addRoute('appid', new Zend_Controller_Router_Route('appid/:appid/:module/:controller/:action/', array(), array(2=> "module", 3=> "controller", 4=> "action")));
but won't works!
some helps?
Try:
<?php
//-------------------------
// Get router from front
// controller
$router = $this->frontController->getRouter();
//-------------------------
// Create route
$route = new Zend_Controller_Router_Route(
'controller/action/:appid/:param1',
array(
'module' => default',
'controller' => 'index',
'action' => 'index',
'appid' => '',
'param1' => 'default_value'
),
//-------------------------
// You can even add a regex
// to parameters. Example,
// appid can only be an integer
array(
'appid' => '\d+'
)
);
//-------------------------
// Add route to Router
$router->addRoute('appid', $route);
?>
Of'course, you'll need to substitute a few things (module, controller, action and parameters). If you're not using modules, simply delete it from the array.
Finally, to use the route in the view, you can use:
$this->url(array('appid' => 1, 'param1' => 'custom_value'),'appid');
UPDATE:
You can try the following in your
<VirtualHost>
RewriteEngine On
RewriteRule ^/appid/(.*) /module/controller/action/$1 [R=301,L]
</VirtualHost>
If you don't need to use a permanent 301 redirect, you can drop the R
精彩评论