From 2c8a96b734ba1e8215e65727bfc2eb6b38a37a80 Mon Sep 17 00:00:00 2001 From: "thibault.raquet" Date: Wed, 31 Jul 2024 13:00:31 +0200 Subject: [PATCH] add redirect-www-to-no-www middleware --- infrastructure/traefik/helm-release.yaml | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/infrastructure/traefik/helm-release.yaml b/infrastructure/traefik/helm-release.yaml index 0d621fc..dc32718 100644 --- a/infrastructure/traefik/helm-release.yaml +++ b/infrastructure/traefik/helm-release.yaml @@ -106,6 +106,51 @@ spec: # How to modify the URL to have the new target URL replacement: "https://${1}" + - apiVersion: traefik.io/v1alpha1 # Redirect www URLs to their no-www equivalent + kind: Middleware + metadata: + name: redirect-www-to-no-www + namespace: production + spec: + # Redirect a request from an url to another with regex matching and replacement + redirectRegex: + # Apply a permanent redirection (HTTP 301) + permanent: true + # The regular expression to match and capture elements from the request URL + regex: "^https?://www\\.(.+)" + # How to modify the URL to have the new target URL + replacement: "https://${1}" + + - apiVersion: traefik.io/v1alpha1 # Redirect www URLs to their no-www equivalent + kind: Middleware + metadata: + name: redirect-www-to-no-www + namespace: staging + spec: + # Redirect a request from an url to another with regex matching and replacement + redirectRegex: + # Apply a permanent redirection (HTTP 301) + permanent: true + # The regular expression to match and capture elements from the request URL + regex: "^https?://www\\.(.+)" + # How to modify the URL to have the new target URL + replacement: "https://${1}" + + - apiVersion: traefik.io/v1alpha1 # Redirect www URLs to their no-www equivalent + kind: Middleware + metadata: + name: redirect-www-to-no-www + namespace: review + spec: + # Redirect a request from an url to another with regex matching and replacement + redirectRegex: + # Apply a permanent redirection (HTTP 301) + permanent: true + # The regular expression to match and capture elements from the request URL + regex: "^https?://www\\.(.+)" + # How to modify the URL to have the new target URL + replacement: "https://${1}" + # Redirection to www for common-services namespace # TODO: remove this middleware when all sites been updated - apiVersion: traefik.io/v1alpha1 # Redirect no-www URLs to their www equivalent