I want to redirect the main domain in Kubernetes ingress Nginx but would like subdomains to get applied to the redirected main domain.
Here is the example website: my.website.com
Inside this website there are many subdomains which are /abc, /def, /abc/aa, /def/bb, etc.
For my Kubernetes ingress Nginx, I want to redirect my.website.com to this.website.com and also would like all subdomains to redirect to this.website.com
Here is the example that I want:
my.website.com/abc
to this.website.com/abc
Here is the redirect ingress yaml that I tried:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/permanent-redirect: https://this.website.com
name: redirect-subdomains-too
spec:
rules:
- host: my.website.com
http:
paths:
- backend:
serviceName: redirect-service
servicePort: 7990
path: /
Obviously, when I try my.website.com/abc
OR my.website.com/abc/aa
this will redirect to this.website.com
not to this.website.com/abc
OR this.website.com/abc/aa
.
How can I script this ingress?