add redirect-www-to-no-www middleware

This commit is contained in:
thibault.raquet 2024-07-31 13:00:31 +02:00
parent 1430226090
commit 2c8a96b734

View file

@ -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