zend routing works only in lowercase letters

250 views Asked by At

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
2

There are 2 answers

1
takeshin On BEST ANSWER

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);
}
0
Martijn On

I've searched Google for a few minutes, and this page (http://joshribakoff.com/?p=29) covers a nice patch. This patch overrides the request object, instead of the dispatcher or the router.