Site icon Hip-Hop Website Design and Development

issue with wordpress [wp-admin] redirects, when using kubernetes ingress hosting two wordpress websites using path

i’m trying to setup a kubernetes deployment for two wordpress websites in different pods, each will have it’s own deployment and service, etc…, under the same ingress, i have setup the ingress this way :

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/use-regex: "true"
  labels:
    app: app-1
    built-by: kustomize
  name: app-1
  namespace: namespace-1
spec:
  ingressClassName: nginx
  rules:
- host: test.sub.website.com
    http:
      paths:
      - backend:
          service:
            name: wordpress-service-1
            port:
              number: 80
        path: /(.*)
        pathType: Prefix
  - host: test.sub.website.com
    http:
      paths:
      - backend:
          service:
            name: wordpress-service-2
            port:
              number: 80
        path: /path/wordpress2(?:/|$)(.*)
        pathType: Prefix
  tls:
  - hosts:
    - test.sub.website.com
    secretName: app-cert
status:
  loadBalancer:
    ingress:
    - hostname: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.elb.ap-northeast-1.amazonaws.com

This is my apache file :

<Directory /var/www/html>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    <IfModule mod_negotiation.c>
            Options -MultiViews
    </IfModule>
    Options FollowSymLinks
    AllowOverride ALL
  </Directory>

and this is how i set up wp_home and wp_siteurl on my second wordpress service wp-config.php :

define( 'WP_HOME', 'https://test.sub.website.com/path/wordpress2/' );
define( 'WP_SITEURL', 'https://test.sub.website.com/path/wordpress2/' );

I barely managed to make it work so that each path "/" or "/path/wordpress2" goes to it’s respective service, the issue here is that on the second path "/path/wordpress2", when i try to access the admin page "test.sub.website.com/path/wordpress2/wp-admin, it redirects me to the "/" admin page "test.sub.website.com/wp-admin/", i tried alot of things but it didn’t work, not only "wp-login" but also "wp-admin" and i believe also when logging out, is there a way to fix this from kubernetes using the server-snippet annotation ? or maybe editing wordpress config files or apache files ?

Is there a way to edit the wordpress redirection to remove this behavior ?