帮助创建 Zend 框架重定向


Help creating Zend Framework Redirect

我正在尝试创建一个 mod 重写表达式以从 localhost/1234 重定向到 localhost/controller/action?param=1234。

我的 bootstrap.php 中有以下内容,它以本地主机/数字的形式重定向所有请求

$routePublic = new Zend_Controller_Router_Route_Regex('^['d]+('.['d]+){0,1}$', array( 1 => '' ,'controller' => 'content', 'action' => 'public'));

但是,我需要将参数传递给我的公共操作。

感谢您的帮助。像我这样的新手比你想象的更欣赏它!

试试这个:

$frontController = Zend_Controller_Front::getInstance();
$frontController->getRouter()->addRoute('name_of_route', 
            new Zend_Controller_Router_Route('/url_of_route/*', 
            array('controller'=>'controller_you_want_to_call','action'=>'action_you_want_to_call')));

请注意,"url_of_route"后面的"*"就像一个通配符,这意味着任何东西都可以在它之后出现

这里还有一个好文章的链接