Wednesday, March 16, 2011

Best way to change default homepage in Zend Framework

Hi all,

Right now ZF defaults to /

I would really like / to redirect to /sort/all

I've changed my default route in routes.ini to

routes.default.route = "/:controller/:filter"
routes.default.defaults.controller = sort
routes.default.defaults.action = sort
routes.default.defaults.filter = all

which displays correctly but the URL doesn't change.

I don't want a user to bring up / , but i still have /contact /about so i can't just move the install path

Its probably an htaccess issue, but i didn't want to break zend default dispatching.

From stackoverflow
  • I would really like / to redirect to /sort/all

    How about letting IndexController::indexAction() just contain:

    return $this->_redirect('/sort/all');
    

    That would be easy to maintain once you'd want to use the root uri for something else.

    bonez : duh. i've been working too many hours straight :) Thank you much, chelmertz
    chelmertz : You should probably check out the method which generates headers that suits your needs the most ("temporarily moved" vs "permanently moved" for example.)

0 comments:

Post a Comment