getRequestTarget(), '/api/v1')) { return $response->withStatus(404); } // This is required because the middleware is ignored if the route is not found. $this->container->basePath = rtrim($request->getUri()->getBasePath(), '/'); $this->assignView('error_message', t('Requested page could not be found.')); return $response->withStatus(404)->write($this->render('404')); } }