getUri(); if (preg_match("/^(.*&)*logintype=logout(&.*)*$/", $uri->getQuery())) { // this is a logout request, and it has already been handled by the // auth service. $newQuery = preg_replace("/logintype=logout&?/", '', $uri->getQuery()); return new RedirectResponse( $uri->withQuery($newQuery), 303, ['X-Redirect-By' => 'OtTemplating logout redirection'] ); } // just pass the plate to the next middleware... return $handler->handle($request); } }