Rails.application.routes.draw do
  # Pages and guides that have been renamed (and we don't want to break old URLs)

  get "/docs/agent/clusters",                                              to: redirect("/docs/clusters/overview")
  get "/docs/agent/v3/agent-stack-k8s/setting-up-hooks-and-plugins",       to: redirect("/docs/agent/v3/agent-stack-k8s/agent-hooks-and-plugins")
  get "/docs/agent/v3/aws/secrets-manager",                                to: redirect("/docs/agent/v3/aws/elastic-ci-stack/ec2-linux-and-windows/secrets-manager")
  get "/docs/agent/v3/aws/vpc",                                            to: redirect("/docs/agent/v3/aws/architecture/vpc")
  get "/docs/agent/v3/elastic-ci-stack-for-ec2-mac/autoscaling-mac-metal", to: redirect("/docs/agent/v3/aws/elastic-ci-stack/ec2-mac/setup")
  get "/docs/agent/v3/elastic-ci-stack-for-ec2-mac/troubleshooting",       to: redirect("/docs/agent/v3/aws/elastic-ci-stack/ec2-mac/troubleshooting")
  get "/docs/agent/v3/elastic-ci-aws",                                     to: redirect("/docs/agent/v3/aws/elastic-ci-stack/ec2-linux-and-windows/setup")
  get "/docs/agent/v3/elastic-ci-aws/cloudformation-service-role",         to: redirect("/docs/agent/v3/aws/elastic-ci-stack/ec2-linux-and-windows/cloudformation-service-role")
  get "/docs/agent/v3/elastic-ci-aws/elastic-ci-stack-overview",           to: redirect("/docs/agent/v3/aws/elastic-ci-stack")
  get "/docs/agent/v3/elastic-ci-aws/managing-elastic-ci-stack",           to: redirect("/docs/agent/v3/aws/elastic-ci-stack/ec2-linux-and-windows/managing-elastic-ci-stack")
  get "/docs/agent/v3/elastic-ci-aws/parameters",                          to: redirect("/docs/agent/v3/aws/elastic-ci-stack/ec2-linux-and-windows/template-parameters")
  get "/docs/agent/v3/elastic-ci-aws/secrets-bucket",                      to: redirect("/docs/agent/v3/aws/elastic-ci-stack/ec2-linux-and-windows/secrets-bucket")
  get "/docs/agent/v3/elastic-ci-aws/security",                            to: redirect("/docs/agent/v3/aws/elastic-ci-stack/ec2-linux-and-windows/security")
  get "/docs/agent/v3/elastic-ci-aws/troubleshooting",                     to: redirect("/docs/agent/v3/aws/elastic-ci-stack/ec2-linux-and-windows/troubleshooting")
  get "/docs/agent/v3/osx",                                                to: redirect("/docs/agent/v3/macos")
  get "/docs/agent/v3/plugins",                                            to: redirect("/docs/pipelines/integrations/plugins")
  get "/docs/agent/v3/upgrading",                                          to: redirect("/docs/agent/v3/installation#upgrade-agents")
  get "/docs/api",                                                         to: redirect("/docs/apis/rest-api")
  get "/docs/api/accounts",                                                to: redirect("/docs/apis/rest-api/organizations")
  get "/docs/api/organizations",                                           to: redirect("/docs/apis/rest-api/organizations")
  get "/docs/api/projects",                                                to: redirect("/docs/apis/rest-api/pipelines")
  get "/docs/api/*page",                                                   to: redirect("/docs/apis/rest-api/%{page}")
  get "/docs/apis/graphql/cookbooks/packages",                             to: redirect("/docs/apis/graphql/cookbooks/registries")
  get "/docs/apis/graphql-tutorial",                                       to: redirect("/docs/apis/graphql/graphql-tutorial")
  get "/docs/apis/graphql",                                                to: redirect("/docs/apis/graphql-api")
  get "/docs/apis/graphql/schemas",                                        to: redirect("/docs/apis/graphql-api")
  get "/docs/apis/graphql/schemas/query",                                  to: redirect("/docs/apis/graphql-api")
  get "/docs/apis/graphql/schemas/mutation",                               to: redirect("/docs/apis/graphql-api")
  get "/docs/apis/graphql/schemas/object",                                 to: redirect("/docs/apis/graphql-api")
  get "/docs/apis/graphql/schemas/scalar",                                 to: redirect("/docs/apis/graphql-api")
  get "/docs/apis/graphql/schemas/interface",                              to: redirect("/docs/apis/graphql-api")
  get "/docs/apis/graphql/schemas/enum",                                   to: redirect("/docs/apis/graphql-api")
  get "/docs/apis/graphql/schemas/input-object",                           to: redirect("/docs/apis/graphql-api")
  get "/docs/apis/graphql/schemas/union",                                  to: redirect("/docs/apis/graphql-api")
  get "/docs/apis/rest-api/analytics/*page",                               to: redirect("/docs/apis/rest-api/test-engine/%{page}")
  get "/docs/apis/rest-api/packages/*page",                                to: redirect("/docs/apis/rest-api/package-registries/%{page}")
  get "/docs/apis/webhooks/agent-events",                                  to: redirect("/docs/apis/webhooks/pipelines/agent-events")
  get "/docs/apis/webhooks/build-events",                                  to: redirect("/docs/apis/webhooks/pipelines/build-events")
  get "/docs/apis/webhooks/agent-token-events",                            to: redirect("/docs/apis/webhooks/pipelines/agent-token-events")
  get "/docs/apis/webhooks/job-events",                                    to: redirect("/docs/apis/webhooks/pipelines/job-events")
  get "/docs/apis/webhooks/ping-events",                                   to: redirect("/docs/apis/webhooks/pipelines/ping-events")
  get "/docs/apis/webhooks/integrations",                                  to: redirect("/docs/apis/webhooks/pipelines/integrations")
  get "/docs/basics/pipelines",                                            to: redirect("/docs/pipelines")
  get "/docs/builds",                                                      to: redirect("/docs/tutorials")
  get "/docs/builds/parallelizing-builds",                                 to: redirect("/docs/pipelines/tutorials/parallel-builds")
  get "/docs/builds/scheduled-builds",                                     to: redirect("/docs/pipelines/scheduled-builds")
  get "/docs/builds/build-status-badges",                                  to: redirect("/docs/pipelines/integrations/other/build-status-badges")
  get "/docs/builds/cc-menu",                                              to: redirect("/docs/pipelines/integrations/other/cc-menu")
  get "/docs/builds/docker-containerized-builds",                          to: redirect("/docs/pipelines/tutorials/docker-containerized-builds")
  get "/docs/builds/*page",                                                to: redirect("/docs/pipelines/%{page}")
  get "/docs/cli",                                                         to: redirect("/docs/platform/cli")
  get "/docs/cli/*page",                                                   to: redirect("/docs/platform/cli/%{page}")
  get "/docs/clusters/overview",                                           to: redirect("/docs/pipelines/clusters")
  get "/docs/clusters/manage-clusters",                                    to: redirect("/docs/pipelines/clusters/manage-clusters")
  get "/docs/clusters/manage-queues",                                      to: redirect("/docs/pipelines/clusters/manage-queues")
  get "/docs/clusters/queue-metrics",                                      to: redirect("/docs/pipelines/insights/queue-metrics")
  get "/docs/deployments",                                                 to: redirect("/docs/pipelines/deployments")
  get "/docs/deployments/deploying-to-heroku",                             to: redirect("/docs/pipelines/deployments/to-heroku")
  get "/docs/deployments/deploying-to-kubernetes",                         to: redirect("/docs/pipelines/deployments/to-kubernetes")
  get "/docs/guides/artifacts",                                            to: redirect("/docs/pipelines/artifacts")
  get "/docs/guides/branch-configuration",                                 to: redirect("/docs/pipelines/branch-configuration")
  get "/docs/guides/build-meta-data",                                      to: redirect("/docs/pipelines/build-meta-data")
  get "/docs/guides/build-status-badges",                                  to: redirect("/docs/pipelines/integrations/other/build-status-badges")
  get "/docs/guides/cc-menu",                                              to: redirect("/docs/pipelines/integrations/other/cc-menu")
  get "/docs/guides/collapsing-build-output",                              to: redirect("/docs/pipelines/managing-log-output#collapsing-output")
  get "/docs/guides/controlling-concurrency",                              to: redirect("/docs/pipelines/controlling-concurrency")
  get "/docs/guides/deploying-to-heroku",                                  to: redirect("/docs/deployments/deploying-to-heroku")
  get "/docs/guides/docker-containerized-builds",                          to: redirect("/docs/pipelines/tutorials/docker-containerized-builds")
  get "/docs/guides/elastic-ci-stack-aws",                                 to: redirect("/docs/tutorials/elastic-ci-stack-aws")
  get "/docs/guides/environment-variables",                                to: redirect("/docs/pipelines/environment-variables")
  get "/docs/guides/getting-started",                                      to: redirect("/docs/tutorials")
  get "/docs/guides/github-enterprise",                                    to: redirect("/docs/pipelines/source-control/github-enterprise")
  get "/docs/guides/github-repo-access",                                   to: redirect("/docs/agent/github-ssh-keys")
  get "/docs/guides/gitlab",                                               to: redirect("/docs/pipelines/source-control/gitlab")
  get "/docs/guides/images-in-build-output",                               to: redirect("/docs/pipelines/links-and-images-in-log-output")
  get "/docs/guides/managing-log-output",                                  to: redirect("/docs/pipelines/managing-log-output")
  get "/docs/guides/migrating-from-bamboo",                                to: redirect("/docs/pipelines/migration/from-bamboo")
  get "/docs/guides/parallelizing-builds",                                 to: redirect("/docs/pipelines/tutorials/parallel-builds")
  get "/docs/guides/skipping-a-build",                                     to: redirect("/docs/pipelines/ignoring-a-commit")
  get "/docs/guides/uploading-pipelines",                                  to: redirect("/docs/pipelines/defining-steps")
  get "/docs/guides/writing-build-scripts",                                to: redirect("/docs/pipelines/writing-build-scripts")
  get "/docs/graphql-api",                                                 to: redirect("/docs/apis/graphql-api")
  get "/docs/graphql",                                                     to: redirect("/docs/apis/graphql-api")
  get "/docs/how-tos",                                                     to: redirect("/docs/tutorials")
  get "/docs/how-tos/bitbucket",                                           to: redirect("/docs/pipelines/source-control/bitbucket")
  get "/docs/how-tos/github-enterprise",                                   to: redirect("/docs/pipelines/source-control/github-enterprise")
  get "/docs/how-tos/gitlab",                                              to: redirect("/docs/pipelines/source-control/gitlab")
  get "/docs/how-tos/deploying-to-heroku",                                 to: redirect("/docs/deployments/deploying-to-heroku")
  get "/docs/how-tos/migrating-from-bamboo",                               to: redirect("/docs/pipelines/migration/from-bamboo")
  get "/docs/integrations",                                                to: redirect("/docs/pipelines/integrations")
  get "/docs/integrations/amazon-eventbridge",                             to: redirect("/docs/pipelines/integrations/observability/amazon-eventbridge")
  get "/docs/integrations/artifactory",                                    to: redirect("/docs/pipelines/integrations/other/artifactory")
  get "/docs/integrations/bitbucket",                                      to: redirect("/docs/pipelines/source-control/bitbucket")
  get "/docs/integrations/bitbucket-server",                               to: redirect("/docs/pipelines/source-control/bitbucket-server")
  get "/docs/integrations/build-status-badges",                            to: redirect("/docs/pipelines/integrations/other/build-status-badges")
  get "/docs/integrations/cc-menu",                                        to: redirect("/docs/pipelines/integrations/other/cc-menu")
  get "/docs/integrations/docker-hub",                                     to: redirect("/docs/pipelines/integrations/other/docker-hub")
  get "/docs/integrations/git",                                            to: redirect("/docs/pipelines/source-control/git")
  get "/docs/integrations/github",                                         to: redirect("/docs/pipelines/source-control/github")
  get "/docs/integrations/github-enterprise",                              to: redirect("/docs/pipelines/source-control/github-enterprise")
  get "/docs/integrations/gitlab",                                         to: redirect("/docs/pipelines/source-control/gitlab")
  get "/docs/integrations/pagerduty",                                      to: redirect("/docs/pipelines/integrations/other/pagerduty")
  get "/docs/integrations/phabricator",                                    to: redirect("/docs/pipelines/source-control/phabricator")
  get "/docs/integrations/slack",                                          to: redirect("/docs/pipelines/integrations/notifications/slack")
  get "/docs/integrations/slack-workspace",                                to: redirect("/docs/pipelines/integrations/notifications/slack-workspace")
  get "/docs/integrations/source-control",                                 to: redirect("/docs/pipelines/source-control")
  get "/docs/integrations/sso",                                            to: redirect("/docs/platform/sso")
  get "/docs/integrations/sso/google-oauth",                               to: redirect("/docs/platform/sso/google-workspace")
  get "/docs/integrations/sso/g-suite",                                    to: redirect("/docs/platform/sso/google-workspace")
  get "/docs/integrations/sso/cloud-identity",                             to: redirect("/docs/platform/sso/google-workspace-saml")
  get "/docs/integrations/sso/g-cloud-identity",                           to: redirect("/docs/platform/sso/google-workspace-saml")
  get "/docs/integrations/sso/*page",                                      to: redirect("/docs/platform/sso/%{page}")
  get "/docs/package-registries/alpine",                                   to: redirect("/docs/package-registries/ecosystems/alpine")
  get "/docs/package-registries/container",                                to: redirect("/docs/package-registries/ecosystems/oci")
  get "/docs/package-registries/debian",                                   to: redirect("/docs/package-registries/ecosystems/debian")
  get "/docs/package-registries/ecosystems/container",                     to: redirect("/docs/package-registries/ecosystems/oci")
  get "/docs/package-registries/files",                                    to: redirect("/docs/package-registries/ecosystems/files")
  get "/docs/package-registries/gradle-groovy",                            to: redirect("/docs/package-registries/ecosystems/gradle-groovy")
  get "/docs/package-registries/gradle-kotlin",                            to: redirect("/docs/package-registries/ecosystems/gradle-kotlin")
  get "/docs/package-registries/gradle",                                   to: redirect("/docs/package-registries/ecosystems/gradle")
  get "/docs/package-registries/helm-oci",                                 to: redirect("/docs/package-registries/ecosystems/helm-oci")
  get "/docs/package-registries/helm",                                     to: redirect("/docs/package-registries/ecosystems/helm")
  get "/docs/package-registries/hugging-face",                             to: redirect("/docs/package-registries/ecosystems/hugging-face")
  get "/docs/package-registries/javascript",                               to: redirect("/docs/package-registries/ecosystems/javascript")
  get "/docs/package-registries/manage-registries",                        to: redirect("/docs/package-registries/registries/manage")
  get "/docs/package-registries/maven",                                    to: redirect("/docs/package-registries/ecosystems/maven")
  get "/docs/package-registries/private-storage",                          to: redirect("/docs/package-registries/registries/private-storage-link")
  get "/docs/package-registries/private-storage-link",                     to: redirect("/docs/package-registries/registries/private-storage-link")
  get "/docs/package-registries/private-storage-link/amazon-s3",           to: redirect("/docs/package-registries/registries/private-storage-link/amazon-s3")
  get "/docs/package-registries/private-storage-link/google-cloud-storage",to: redirect("/docs/package-registries/registries/private-storage-link/google-cloud-storage")
  get "/docs/package-registries/python",                                   to: redirect("/docs/package-registries/ecosystems/python")
  get "/docs/package-registries/red-hat",                                  to: redirect("/docs/package-registries/ecosystems/red-hat")
  get "/docs/package-registries/ruby",                                     to: redirect("/docs/package-registries/ecosystems/ruby")
  get "/docs/package-registries/terraform",                                to: redirect("/docs/package-registries/ecosystems/terraform")
  get "/docs/packages",                                                    to: redirect("/docs/package-registries")
  get "/docs/packages/*page",                                              to: redirect("/docs/package-registries/%{page}")
  get "/docs/packages/manage-repositories",                                to: redirect("/docs/package-registries/manage-registries")
  get "/docs/packages/nodejs",                                             to: redirect("/docs/package-registries/javascript")
  get "/docs/packages/permissions",                                        to: redirect("/docs/package-registries/security/permissions")
  get "/docs/pipelines/archiving-and-deleting-pipelines",                  to: redirect("/docs/pipelines/configure/workflows/archiving-and-deleting-pipelines")
  get "/docs/pipelines/artifacts",                                         to: redirect("/docs/pipelines/configure/artifacts")
  get "/docs/pipelines/audit-log",                                         to: redirect("/docs/platform/audit-log")
  get "/docs/pipelines/block-step",                                        to: redirect("/docs/pipelines/configure/step-types/block-step")
  get "/docs/pipelines/branch-configuration",                              to: redirect("/docs/pipelines/configure/workflows/branch-configuration")
  get "/docs/pipelines/build-exports",                                     to: redirect("/docs/pipelines/governance/build-exports")
  get "/docs/pipelines/build-matrix",                                      to: redirect("/docs/pipelines/configure/workflows/build-matrix")
  get "/docs/pipelines/build-meta-data",                                   to: redirect("/docs/pipelines/configure/build-meta-data")
  get "/docs/pipelines/build-retention",                                   to: redirect("/docs/pipelines/configure/build-retention")
  get "/docs/pipelines/build-timeouts",                                    to: redirect("/docs/pipelines/configure/build-timeouts")
  get "/docs/pipelines/cluster-queue-metrics",                             to: redirect("/docs/pipelines/insights/queue-metrics")
  get "/docs/pipelines/clusters/queue-metrics",                            to: redirect("/docs/pipelines/insights/queue-metrics")
  get "/docs/pipelines/controlling-concurrency",                           to: redirect("/docs/pipelines/configure/workflows/controlling-concurrency")
  get "/docs/pipelines/command-step",                                      to: redirect("/docs/pipelines/configure/step-types/command-step")
  get "/docs/pipelines/conditionals",                                      to: redirect("/docs/pipelines/configure/conditionals")
  get "/docs/pipelines/configuration-overview",                            to: redirect("/docs/pipelines/configure")
  get "/docs/pipelines/controlling-concurrency",                           to: redirect("/docs/pipelines/configure/workflows/controlling-concurrency")
  get "/docs/pipelines/defining-steps",                                    to: redirect("/docs/pipelines/configure/defining-steps")
  get "/docs/pipelines/dependencies",                                      to: redirect("/docs/pipelines/configure/dependencies")
  get "/docs/pipelines/deployments/to-heroku",                             to: redirect("/docs/pipelines/deployments/with-heroku")
  get "/docs/pipelines/emoji",                                             to: redirect("/docs/platform/emojis")
  get "/docs/pipelines/emojis",                                            to: redirect("/docs/platform/emojis")
  get "/docs/pipelines/example-pipelines",                                 to: redirect("/docs/pipelines/configure/example-pipelines")
  get "/docs/pipelines/environment-variables",                             to: redirect("/docs/pipelines/configure/environment-variables")
  get "/docs/pipelines/group-step",                                        to: redirect("/docs/pipelines/configure/step-types/group-step")
  get "/docs/pipelines/hosted-agents/overview",                            to: redirect("/docs/pipelines/hosted-agents")
  get "/docs/pipelines/hosted-agents/mac",                                 to: redirect("/docs/pipelines/hosted-agents/macos")
  get "/docs/pipelines/ignoring-a-commit",                                 to: redirect("/docs/pipelines/skipping#ignore-a-commit")
  get "/docs/pipelines/images-in-log-output",                              to: redirect("/docs/pipelines/links-and-images-in-log-output")
  get "/docs/pipelines/incoming-webhooks",                                 to: redirect("/docs/pipelines/security/incoming-webhooks")
  get "/docs/pipelines/input-step",                                        to: redirect("/docs/pipelines/configure/step-types/input-step")
  get "/docs/pipelines/integrations/other/amazon-eventbridge",             to: redirect("/docs/pipelines/integrations/observability/amazon-eventbridge")
  get "/docs/pipelines/integrations/other/cc-menu",                        to: redirect("/docs/pipelines/integrations/notifications/cc-menu")
  get "/docs/pipelines/integrations/other/artifactory",                    to: redirect("/docs/pipelines/integrations/artifacts-and-packages/artifactory")
  get "/docs/pipelines/integrations/other/pagerduty",                      to: redirect("/docs/pipelines/integrations/notifications/pagerduty")
  get "/docs/pipelines/integrations/other/slack",                          to: redirect("/docs/pipelines/integrations/notifications/slack")
  get "/docs/pipelines/integrations/other/slack-workspace",                to: redirect("/docs/pipelines/integrations/notifications/slack-workspace")
  get "/docs/pipelines/job-minutes",                                       to: redirect("/docs/pipelines/configure/job-minutes")
  get "/docs/pipelines/links-and-images-in-log-output",                    to: redirect("/docs/pipelines/configure/links-and-images-in-log-output")
  get "/docs/pipelines/managing-log-output",                               to: redirect("/docs/pipelines/configure/managing-log-output")
  get "/docs/pipelines/managing-priorities",                               to: redirect("/docs/pipelines/configure/workflows/managing-priorities")
  get "/docs/pipelines/migrate-from-jenkins",                              to: redirect("/docs/pipelines/migration/from-jenkins")
  get "/docs/pipelines/migration-overview",                                to: redirect("/docs/pipelines/migration")
  get "/docs/pipelines/notifications",                                     to: redirect("/docs/pipelines/configure/notifications")
  get "/docs/pipelines/parallel-builds",                                   to: redirect("/docs/pipelines/tutorials/parallel-builds")
  get "/docs/pipelines/permissions",                                       to: redirect("/docs/pipelines/security/permissions")
  get "/docs/pipelines/pipelines",                                         to: redirect("/docs/pipelines")
  get "/docs/pipelines/plugins",                                           to: redirect("/docs/pipelines/integrations/plugins")
  get "/docs/pipelines/public-pipelines",                                  to: redirect("/docs/pipelines/configure/public-pipelines")
  get "/docs/pipelines/scheduled-builds",                                  to: redirect("/docs/pipelines/configure/workflows/scheduled-builds")
  get "/docs/pipelines/secrets",                                           to: redirect("/docs/pipelines/security/secrets/managing")
  get "/docs/pipelines/security/overview",                                 to: redirect("/docs/pipelines/security")
  get "/docs/pipelines/security-overview",                                 to: redirect("/docs/pipelines/security")
  get "/docs/pipelines/security/audit-log",                                to: redirect("/docs/platform/audit-log")
  get "/docs/pipelines/security/managing-secrets",                         to: redirect("/docs/pipelines/security/secrets/managing")
  get "/docs/pipelines/skipping",                                          to: redirect("/docs/pipelines/configure/skipping")
  get "/docs/pipelines/step-reference",                                    to: redirect("/docs/pipelines/configure/step-types")
  get "/docs/pipelines/tags",                                              to: redirect("/docs/pipelines/configure/tags")
  get "/docs/pipelines/templates",                                         to: redirect("/docs/pipelines/governance/templates")
  get "/docs/pipelines/trigger-step",                                      to: redirect("/docs/pipelines/configure/step-types/trigger-step")
  get "/docs/pipelines/uploading-pipelines",                               to: redirect("/docs/pipelines/defining-steps")
  get "/docs/pipelines/wait-step",                                         to: redirect("/docs/pipelines/configure/step-types/wait-step")
  get "/docs/pipelines/waterfall",                                         to: redirect("/docs/pipelines/insights/waterfall")
  get "/docs/pipelines/writing-build-scripts",                             to: redirect("/docs/pipelines/configure/writing-build-scripts")
  get "/docs/plugins",                                                     to: redirect("/docs/pipelines/integrations/plugins")
  get "/docs/plugins/using",                                               to: redirect("/docs/pipelines/integrations/plugins/using")
  get "/docs/plugins/directory",                                           to: redirect("/docs/pipelines/integrations/plugins/directory")
  get "/docs/plugins/tools",                                               to: redirect("/docs/pipelines/integrations/plugins/writing#plugin-tools")
  get "/docs/projects",                                                    to: redirect("/docs/pipelines")
  get "/docs/quickstart/*page",                                            to: redirect("/docs/tutorials/%{page}")
  get "/docs/rest-api",                                                    to: redirect("/docs/apis/rest-api")
  get "/docs/rest-api/*page",                                              to: redirect("/docs/apis/rest-api/%{page}")
  get "/docs/team-management",                                             to: redirect("/docs/platform/team-management")
  get "/docs/team-management/*page",                                       to: redirect("/docs/platform/team-management/%{page}")
  get "/docs/test-analytics",                                              to: redirect("/docs/test-engine")
  get "/docs/test-analytics/*page",                                        to: redirect("/docs/test-engine/%{page}")
  get "/docs/test-analytics/js-collectors",                                to: redirect("/docs/test-engine/javascript-collectors")
  get "/docs/test-engine/android-collectors",                              to: redirect("/docs/test-engine/test-collection/android-collectors")
  get "/docs/test-engine/ci-environments",                                 to: redirect("/docs/test-engine/test-collection/ci-environments")
  get "/docs/test-engine/dotnet-collectors",                               to: redirect("/docs/test-engine/test-collection/dotnet-collectors")
  get "/docs/test-engine/elixir-collectors",                               to: redirect("/docs/test-engine/test-collection/elixir-collectors")
  get "/docs/test-engine/flaky-test-management",                           to: redirect("/docs/test-engine/reduce-flaky-tests")
  get "/docs/test-engine/golang-collectors",                               to: redirect("/docs/test-engine/test-collection/golang-collectors")
  get "/docs/test-engine/importing-json",                                  to: redirect("/docs/test-engine/test-collection/importing-json")
  get "/docs/test-engine/importing-junit-xml",                             to: redirect("/docs/test-engine/test-collection/importing-junit-xml")
  get "/docs/test-engine/javascript-collectors",                           to: redirect("/docs/test-engine/test-collection/javascript-collectors")
  get "/docs/test-engine/labels",                                          to: redirect("/docs/test-engine/test-suites/labels")
  get "/docs/test-engine/manage-test-suites",                              to: redirect("/docs/test-engine/getting-started")
  get "/docs/test-engine/other-collectors",                                to: redirect("/docs/test-engine/test-collection/other-collectors")
  get "/docs/test-engine/public-test-suites",                              to: redirect("/docs/test-engine/test-suites/public")
  get "/docs/test-engine/python-collectors",                               to: redirect("/docs/test-engine/test-collection/python-collectors")
  get "/docs/test-engine/quarantine",                                      to: redirect("/docs/test-engine/test-suites/test-state-and-quarantine")
  get "/docs/test-engine/ruby-collectors",                                 to: redirect("/docs/test-engine/test-collection/ruby-collectors")
  get "/docs/test-engine/rust-collectors",                                 to: redirect("/docs/test-engine/test-collection/rust-collectors")
  get "/docs/test-engine/saved-views",                                     to: redirect("/docs/test-engine/test-suites/saved-views")
  get "/docs/test-engine/swift-collectors",                                to: redirect("/docs/test-engine/test-collection/swift-collectors")
  get "/docs/test-engine/tags",                                            to: redirect("/docs/test-engine/test-suites/tags")
  get "/docs/test-engine/test-ownership",                                  to: redirect("/docs/test-engine/test-suites/test-ownership")
  get "/docs/test-engine/test-splitting",                                  to: redirect("/docs/test-engine/speed-up-builds-with-bktec")
  get "/docs/test-engine/test-splitting/client-installation",              to: redirect("/docs/test-engine/bktec/installing-the-client")
  get "/docs/test-engine/test-splitting/configuring",                      to: redirect("/docs/test-engine/bktec/configuring")
  get "/docs/test-engine/test-suite/flaky-test-management",                to: redirect("/docs/test-engine/reduce-flaky-tests")
  get "/docs/test-engine/test-state-and-quarantine",                       to: redirect("/docs/test-engine/test-suites/test-state-and-quarantine")
  get "/docs/test-engine/test-suites/manage",                              to: redirect("/docs/test-engine/getting-started")
  get "/docs/test-engine/notifications/slack",                             to: redirect("/docs/test-engine/workflows/actions#send-slack-notification")
  get "/docs/test-engine/your-own-collectors",                             to: redirect("/docs/test-engine/test-collection/your-own-collectors")
  get "/docs/test-engine/test-suites/permissions",                         to: redirect("/docs/test-engine/permissions")
  get "/docs/tutorials/2fa",                                               to: redirect("/docs/platform/tutorials/2fa")
  get "/docs/tutorials/bazel",                                             to: redirect("/docs/pipelines/tutorials/bazel")
  get "/docs/tutorials/bitbucket",                                         to: redirect("/docs/pipelines/source-control/bitbucket")
  get "/docs/tutorials/custom-saml",                                       to: redirect("/docs/platform/sso/custom-saml")
  get "/docs/tutorials/docker-containerized-builds",                       to: redirect("/docs/pipelines/tutorials/docker-containerized-builds")
  get "/docs/tutorials/deploying-to-heroku",                               to: redirect("/docs/deployments/deploying-to-heroku")
  get "/docs/tutorials/elastic-ci-stack-aws",                              to: redirect("/docs/agent/v3/elastic-ci-aws")
  get "/docs/tutorials/getting-started",                                   to: redirect("/docs/pipelines/getting-started")
  get "/docs/tutorials/gitlab",                                            to: redirect("/docs/pipelines/source-control/gitlab")
  get "/docs/tutorials/github-actions",                                    to: redirect("/docs/pipelines/tutorials/github-actions")
  get "/docs/tutorials/github-enterprise",                                 to: redirect("/docs/pipelines/source-control/github-enterprise")
  get "/docs/tutorials/github-merge-queue",                                to: redirect("/docs/pipelines/tutorials/github-merge-queue")
  get "/docs/tutorials/migrating-from-bamboo",                             to: redirect("/docs/pipelines/migration/from-bamboo")
  get "/docs/tutorials/parallel-builds",                                   to: redirect("/docs/pipelines/tutorials/parallel-builds")
  get "/docs/tutorials/pipeline-upgrade",                                  to: redirect("/docs/pipelines/tutorials/pipeline-upgrade")
  get "/docs/tutorials/sso-setup-with-graphql",                            to: redirect("/docs/platform/sso/sso-setup-with-graphql")
  get "/docs/webhooks/setup",                                              to: redirect("/docs/apis/webhooks")
  get "/docs/webhooks",                                                    to: redirect("/docs/apis/webhooks")
  get "/docs/webhooks/*page",                                              to: redirect("/docs/apis/webhooks/%{page}")

  # Doc sections that don't have overview/index pages, so need redirecting
  get "/docs/tutorials",    to: redirect("/docs/pipelines/getting-started"), status: 302

  # The old un-versioned URLs have a lot of Google juice, so we redirect them to
  # the current version. But these are also linked from within the v2 agent
  # command help, so we may add a notice saying 'Hey, maybe you're looking for
  # v2?' after redirecting.
  get "/docs/agent",                     to: redirect("/docs/agent/v3",                            status: 301)
  get "/docs/agent/installation",        to: redirect("/docs/agent/v3/installation",               status: 301)
  get "/docs/agent/ubuntu",              to: redirect("/docs/agent/v3/ubuntu",                     status: 301)
  get "/docs/agent/debian",              to: redirect("/docs/agent/v3/debian",                     status: 301)
  get "/docs/agent/redhat",              to: redirect("/docs/agent/v3/redhat",                     status: 301)
  get "/docs/agent/freebsd",             to: redirect("/docs/agent/v3/freebsd",                    status: 301)
  get "/docs/agent/osx",                 to: redirect("/docs/agent/v3/macos",                      status: 301)
  get "/docs/agent/windows",             to: redirect("/docs/agent/v3/windows",                    status: 301)
  get "/docs/agent/linux",               to: redirect("/docs/agent/v3/linux",                      status: 301)
  get "/docs/agent/docker",              to: redirect("/docs/agent/v3/docker",                     status: 301)
  get "/docs/agent/aws",                 to: redirect("/docs/agent/v3/aws",                        status: 301)
  get "/docs/agent/gcloud",              to: redirect("/docs/agent/v3/gcloud",                     status: 301)
  get "/docs/agent/configuration",       to: redirect("/docs/agent/v3/configuration",              status: 301)
  get "/docs/agent/ssh-keys",            to: redirect("/docs/agent/v3/ssh-keys",                   status: 301)
  get "/docs/agent/github-ssh-keys",     to: redirect("/docs/agent/v3/github-ssh-keys",            status: 301)
  get "/docs/agent/hooks",               to: redirect("/docs/agent/v3/hooks",                      status: 301)
  get "/docs/agent/queues",              to: redirect("/docs/agent/v3/queues",                     status: 301)
  get "/docs/agent/prioritization",      to: redirect("/docs/agent/v3/prioritization",             status: 301)
  get "/docs/agent/plugins",             to: redirect("/docs/pipelines/integrations/plugins",      status: 301)
  get "/docs/agent/securing",            to: redirect("/docs/agent/v3/securing",                   status: 301)
  get "/docs/agent/cli-start",           to: redirect("/docs/agent/v3/cli-start",                  status: 301)
  get "/docs/agent/cli-meta-data",       to: redirect("/docs/agent/v3/cli-meta-data",              status: 301)
  get "/docs/agent/cli-artifact",        to: redirect("/docs/agent/v3/cli-artifact",               status: 301)
  get "/docs/agent/cli-pipeline",        to: redirect("/docs/agent/v3/cli-pipeline",               status: 301)
  get "/docs/agent/agent-meta-data",     to: redirect("/docs/agent/v3/cli-start#setting-metadata", status: 301)
  get "/docs/agent/artifacts",           to: redirect("/docs/agent/v3/cli-artifact",               status: 301)
  get "/docs/agent/build-artifacts",     to: redirect("/docs/agent/v3/cli-artifact",               status: 301)
  get "/docs/agent/build-meta-data",     to: redirect("/docs/agent/v3/cli-meta-data",              status: 301)
  get "/docs/agent/build-pipelines",     to: redirect("/docs/agent/v3/cli-pipeline",               status: 301)
  get "/docs/agent/uploading-pipelines", to: redirect("/docs/agent/v3/cli-pipeline",               status: 301)
  get "/docs/agent/upgrading",           to: redirect("/docs/agent/v3/upgrading",                  status: 301)
  get "/docs/agent/upgrading-to-v3",     to: redirect("/docs/agent/v3/upgrading",                  status: 301)
  get "/docs/clusters/queue-metrics",    to: redirect("/docs/pipelines/insights/queue-metrics",    status: 301)
  get "/docs/test-engine/java",          to: redirect("/docs/test-engine/importing-junit-xml",     status: 301)

  # Old docs routes that we changed around during the development of the v3 agent docs
  get "/docs/agent/upgrading-to-v2",    to: redirect("/docs/agent/v2/upgrading-to-v2",            status: 301)
  get "/docs/agent/v3/upgrading-to-v3", to: redirect("/docs/agent/v3/upgrading",                  status: 301)
  get "/docs/agent/v2/plugins",         to: redirect("/docs/pipelines/integrations/plugins",      status: 301)
  get "/docs/agent/v2/agent-meta-data", to: redirect("/docs/agent/v2/cli-start#setting-metadata", status: 301)
  get "/docs/agent/v3/agent-meta-data", to: redirect("/docs/agent/v3/cli-start#setting-tags",     status: 301)

  # Pre GA test analytics
  get "/docs/test-analytics/integrations", to: redirect("/docs/test-engine",            status: 301)

  # Quick Reference JSON
  get "/docs/quick-reference/pipelines", to: "quick_reference#pipelines", as: :pipelines_quick_reference

  # LLMs.txt
  get "/docs/llms.txt", to: "llm_text#index", defaults: { format: "txt" }

  # Homepage
  get "/docs" => "pages#index", as: :home_page

  # All other standard docs pages
  get "/docs/*path" => "pages#show", as: :docs_page, constraints: { format: /html|md/ }

  # Content Security Policy violations are sent here, and in production the path is handled by buildkite/buildkite. This is a stub response so CSP violations in development don't generate extra noise in the development log
  post "/_csp-violation-reports", to: proc { [201, {}, ['']] }

  # Take us straight to the docs when running standalone
  root to: redirect("/docs")

  # Ensure 404s for unmatched routes are logged by lograge
  get '*unmatched_route', to: 'application#route_not_found'
end
