Skip to content

Commit e1d81b7

Browse files
chakritGacko
andauthored
Docs: Clarify from-to-www redirect direction. (#11682)
* docs: Clarify from-to-www redirect direction. This was not clear to me when reading the docs whether the ingress will redirect from non-www to with-www or the reverse. It's also not very clear from just grepping around the codebase. I found the answer by reading from this reddit link: https://www.reddit.com/r/kubernetes/comments/pbl033/k8s_ingress_redirecting_www_to_nonwww_domains/ So, to save time for other people doing the same, which I assumes is a lot of people since it's a common scenario, this little revision in the docs is warranted. * Docs: Implement suggestion. --------- Co-authored-by: Marco Ebert <marco_ebert@icloud.com>
1 parent 4b5c5ef commit e1d81b7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/user-guide/nginx-configuration/annotations.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,10 @@ To preserve the trailing slash in the URI with `ssl-redirect`, set `nginx.ingres
655655

656656
### Redirect from/to www
657657

658-
In some scenarios is required to redirect from `www.domain.com` to `domain.com` or vice versa.
658+
In some scenarios, it is required to redirect from `www.domain.com` to `domain.com` or vice versa, which way the redirect is performed depends on the configured `host` value in the Ingress object.
659+
660+
For example, if `.spec.rules.host` is configured with a value like `www.example.com`, then this annotation will redirect to `example.com`. If `.spec.rules.host` is configured with a value like `example.com`, so without a `www`, then this annotation will redirect to `www.example.com` instead.
661+
659662
To enable this feature use the annotation `nginx.ingress.kubernetes.io/from-to-www-redirect: "true"`
660663
661664
!!! attention

internal/ingress/annotations/redirect/redirect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var redirectAnnotations = parser.Annotation{
5151
Validator: parser.ValidateBool,
5252
Scope: parser.AnnotationScopeLocation,
5353
Risk: parser.AnnotationRiskLow, // Low, as it allows just a set of options
54-
Documentation: `In some scenarios is required to redirect from www.domain.com to domain.com or vice versa. To enable this feature use this annotation.`,
54+
Documentation: `In some scenarios, it is required to redirect from www.domain.com to domain.com or vice versa, which way the redirect is performed depends on the configured host value in the Ingress object.`,
5555
},
5656
temporalRedirectAnnotation: {
5757
Validator: parser.ValidateRegex(parser.URLIsValidRegex, false),

0 commit comments

Comments
 (0)