Search code examples
phpzend-framework.htaccessmod-rewritezend-controller-router

Help creating Zend Framework Redirect


I'm trying to create a mod rewrite expression to redirect from localhost/1234 to localhost/controller/action?param=1234.

I have the following in my bootstrap.php, which redirects all requests in the form localhost/number

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

However, I need to pass a param to my publicAction.

Thanks for the help. Newbies like me appreciate it more than you could ever believe!


Solution

  • try this:

    $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')));

    note that the "*" after "url_of_route" is like a wildcard meaning anything can come after it

    Also heres a link to a good article