phpzend-frameworkzend-routezend-controller-router

zend routing works only in lowercase letters


I'm setting up routes in application.ini, so when I try to access /moved, it displays cont/move. It works but only if I type moved all lower letters exactly like it's setup on the first line. How can I make Moved or moVed or any other letter combination also work? Do I need to do it in Bootstrap to get finer control and how?

routes.test.route = moved
routes.test.defaults.controller = cont
routes.test.defaults.action = move

Solution

  • This is not a wise approach.

    URLs are case sensitive for a reason. You will get duplicate content penalty from search engines. Users will be confused too.

    However, you may create controller plugin to achieve this:

    public function preDispatch()
    {
        $this->getRequest()->setControllerName(
            strtolower($this->getRequest()->getControllerName());
        )->setDispatched(false);
    }