Answers: <p>Add an annotation nginx.ingress.kubernetes.io/app-root: /test as per the documentation kubernetes.github.io/ingress-nginx/examples/rewrite/#app-root</p>
  <p>Quoted from the doc and adapted to your exemple, your ingress yaml should look like this (adapt the target service and port):</p>
  <pre><code>apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    annotations:
      nginx.ingress.kubernetes.io/app-root: /test
    name: myapp
    namespace: default
  spec:
    ingressClassName: nginx
    rules:
    - host: myapp.test.com
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: http-svc
              port: 
                number: 80
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2023-05-26T09:13:50.353Z
Answers: 2023-05-26T09:13:50.353Z
Answers: Tensibai
Body: <p>I'm running an application on kubernetes, when i use this url: <a href="https://myapp.test.com/" rel="nofollow noreferrer">https://myapp.test.com/</a> it redirects me to ressource not found (problem in the application).
  what i need now is to avoid this page by redirecting the url/ to url/test where i have the home page of the application.
  Is this possible using Ingress?
  If you can show me please an example of a configuration that does this redirection.
  Thank you.</p>
  
Tags: <nginx><ingress><ingress-nginx>
Title: redirect url/ to url/test using ingress
UserDisplayName: safae
ThreadText: # redirect url/ to url/test using ingress
  
  (Asked by: username_0 on 2023-05-25)
  
  I'm running an application on kubernetes, when i use this url: <https://myapp.test.com/> it redirects me to ressource not found (problem in the application).
  what i need now is to avoid this page by redirecting the url/ to url/test where i have the home page of the application.
  Is this possible using Ingress?
  If you can show me please an example of a configuration that does this redirection.
  Thank you.
  
  **Tags:** nginx, ingress, ingress-nginx
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-05-26. Score: 1
  
  Add an annotation nginx.ingress.kubernetes.io/app-root: /test as per the documentation kubernetes.github.io/ingress-nginx/examples/rewrite/#app-root
  
  Quoted from the doc and adapted to your exemple, your ingress yaml should look like this (adapt the target service and port):
  
  ```
  apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    annotations:
      nginx.ingress.kubernetes.io/app-root: /test
    name: myapp
    namespace: default
  spec:
    ingressClassName: nginx
    rules:
    - host: myapp.test.com
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: http-svc
              port: 
                number: 80
  
  ```
  
  
  ---
  
  