'second same server hosted wordpress website admin page redirects to wrong wordpress admin page

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 with different paths.

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 "/path/wordpress2/wp-admin", it redirects me to the "/wp-admin" admin page, or sometimes when i change the configuration i get "too many redirects" error, i tried alot of things but they didn't work, not only "wp-login" but also "wp-admin" and i believe also when logging out, i believe wordpress is redirecting this but i don't know how to chnage it, is there a way to fix this from kubernetes using the server-snippet annotation ? or maybe editing wordpress config files or apache files ?

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 service wp-config.php :

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

Edit 2: When accessing the wp-admin, it redirect to :

https://test.sub.website.com/path/wordpress2/wp-login.php?redirect_to=https%3A%2F%2Ftest.sub.website.com%2Fwp-admin%2F&reauth=1

instead of (i think, i'm not sure) :

https://test.sub.website.com/path/wordpress2/wp-login.php?redirect_to=https%3A%2F%2Ftest.sub.website.com%2Fpath%2Fwordpress2%2Fwp-admin%2F&reauth=1

Where does wp-admin take this redrirection info from and how to change it ?



Sources

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

Source: Stack Overflow

Solution Source