public function onEventRequest(Application $app, Request $request) { $matcher = $app->getRouter()->getMatcher(); $route = $matcher->match($request->getMethod(), $request->getPathInfo()); if ($route != null) { $request->attributes->set('_route', $route); } if ($matcher->isNeedRedirect()) { $url = $matcher->getRedirectUrl(); $app->setResponse($app->redirect($url, 301)); $app->stopEventPropagation(); } }