'redirect from old sub domain to new sub domain using AWS ING controller

I am trying to migrate from one sub-domain to another sub-domain and have the following ing resource deployed to the sever

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: backend
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-east-2:460:certificate/0a600-490b-47c2-8378-134, arn:aws:acm:us-east-2:460:certificate/43c-f0d7-4970-9e44-9ed, arn:aws:acm:us-east-2:870:certificate/a0483-97-593
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
    alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
    namespace: staging
spec:
  rules:
    - host: test.oldhost.com
      http:
        paths:
          - path: /*
            backend:
              serviceName: backend
              servicePort: 80
    - host: csv.old.com
      http:
        paths:
          - path: /*
            backend:
              serviceName: exporter
              servicePort: 80
    - host: test.newhost.com
      http:
        paths:
          - path: /*
            backend:
              serviceName: backend
              servicePort: 80

how do i setup so that when user accesses test.oldhost.com, they are redirected to test.newhost.com



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source