{"record":{"id":"5a5a9c66f0fc6eac","repo":"symfony/routing","slug":"ambiguous-redirection-settings-use-the-path-or-route","errorCode":null,"errorMessage":"Ambiguous redirection settings, use the \"path\" or \"route\" parameter, not both: \"%s\" and \"%s\" found respectively in \"%s\" routing configuration.","messagePattern":"Ambiguous redirection settings, use the \"path\" or \"route\" parameter, not both: \"(.+?)\" and \"(.+?)\" found respectively in \"(.+?)\" routing configuration\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Controller/RedirectController.php","lineNumber":175,"sourceCode":"            }\n\n            if (null !== $httpsPort && 443 != $httpsPort) {\n                $port = \":$httpsPort\";\n            }\n        }\n\n        $url = $scheme.'://'.$request->getHost().$port.$request->getBaseUrl().$path.$qs;\n\n        return new RedirectResponse($url, $statusCode);\n    }\n\n    public function __invoke(Request $request): Response\n    {\n        $p = $request->attributes->get('_route_params', []);\n\n        if (\\array_key_exists('route', $p)) {\n            if (\\array_key_exists('path', $p)) {\n                throw new \\RuntimeException(\\sprintf('Ambiguous redirection settings, use the \"path\" or \"route\" parameter, not both: \"%s\" and \"%s\" found respectively in \"%s\" routing configuration.', $p['path'], $p['route'], $request->attributes->get('_route')));\n            }\n\n            return $this->redirectAction($request, $p['route'], $p['permanent'] ?? false, $p['ignoreAttributes'] ?? false, $p['keepRequestMethod'] ?? false, $p['keepQueryParams'] ?? false);\n        }\n\n        if (\\array_key_exists('path', $p)) {\n            return $this->urlRedirectAction($request, $p['path'], $p['permanent'] ?? false, $p['scheme'] ?? null, $p['httpPort'] ?? null, $p['httpsPort'] ?? null, $p['keepRequestMethod'] ?? false);\n        }\n\n        throw new \\RuntimeException(\\sprintf('The parameter \"path\" or \"route\" is required to configure the redirect action in \"%s\" routing configuration.', $request->attributes->get('_route')));\n    }\n}\n","sourceCodeStart":157,"sourceCodeEnd":188,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Controller/RedirectController.php#L157-L188","documentation":"RedirectController::__invoke() looks at the route's _route_params and throws a RuntimeException when both 'route' and 'path' keys are present, since the redirect cannot target both another route and a raw path. Exactly one must be configured.","triggerScenarios":"A route annotation/attribute like #[Route(path: '/go', name: 'go', defaults: ['_controller' => RedirectController::class, 'path' => '/', 'route' => 'home'])] specifying both keys, or merged config accidentally combining both.","commonSituations":"Copy-pasting redirect route definitions and leaving a leftover 'path' while adding 'route' (or vice versa); config merging in multi-file route setups.","solutions":["Remove either the 'path' or the 'route' default from the redirect route definition","Use 'route' + optional parameters to redirect to a named route","Use 'path' (optionally with scheme/httpPort/httpsPort) to redirect to a raw URL path"],"exampleFix":"// before\ndefaults: { _controller: 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController', route: 'home', path: '/' }\n// after\ndefaults: { _controller: 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController', route: 'home' }","handlingStrategy":"validation","validationCode":"$defaults = $route->getDefaults();\nif (isset($defaults['route'], $defaults['path'])) {\n    throw new \\InvalidArgumentException('Redirect route must define route or path, not both');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $response = $redirectController->__invoke($request);\n} catch (\\RuntimeException $e) {\n    // report misconfigured redirect route\n}","preventionTips":["Define exactly one of 'route' or 'path' per redirect route","Lint routing config (bin/console lint:routes) in CI","Review redirect defaults when merging config files"],"tags":["php","routing","redirect","configuration"],"backgroundTag":"conflicting-config-options","analyzedSha":"83fa223250b50f4f018c011e101c330e65ac63cc","analyzedAt":"2026-09-14T03:19:46.280Z","contentChangedAt":"2026-09-14T03:19:46.280Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}