<p>I have deployed WordPress on Kubernetes using Bitnami's WordPress chart.<br />
I wanted to host WordPress under a specific path, not on root.<br />
To achieve that, I did the following:</p>
<ul>
<li>modified <code>wp-config.php</code> file:</li>
</ul>
<pre class="lang-php prettyprint-override"><code>define( 'WP_HOME', 'http://example.com/wordpress/' );
define( 'WP_SITEURL', 'http://example.com/wordpress/' );
</code></pre>
<ul>
<li>created Ingress resource to expose WordPress for public access:</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>kind: Ingress
apiVersion: networking.k8s.io/v1beta1
metadata:
  name: my-ingress
  namespace: my-namespace
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/custom-http-errors: '404'
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  tls:
    - hosts:
        - example.com
      secretName: example-tls
  rules:
    - host: example.com
      http:
        paths:
          - path: /wordpress(/|$)(.*)
            pathType: Prefix
            backend:
              serviceName: wordpress-svc
              servicePort: http
</code></pre>
<p>I am able to access example.com/wordpress - I see the default WordPress site:</p>
<p><a href="https://i.stack.imgur.com/FKsLw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FKsLw.png" alt="enter image description here" /></a></p>
<p>However, when I go to the Admin panel (I click the WordPress logo at the top), I am taken there, and the URL changes to &quot;example.com/wp-admin/about.php&quot; - normally, it should be &quot;example.com/wordpress/wp-admin/about.php&quot;.</p>
<p>Even though the panel displays properly:</p>
<p><a href="https://i.stack.imgur.com/hWS66.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hWS66.png" alt="enter image description here" /></a></p>
<p>When I click on any item on the left, I am taken to the wrong site.   For example, clicking on &quot;Users&quot; takes me to &quot;example.com/wp-admin/users.php&quot;. I get 404. However, if I modify the URL manually and change it to &quot;example.com/wordpress/wp-admin/users.php&quot;, the correct page loads (but the URL in my browser again changes to the wrong one, without &quot;WordPress&quot;.</p>
<p>What's the cause of that?<br />
I don't see any 30x in the Network tab of DevTools, so I assume that it's some JavaScript of WordPress that modifies my address bar. How do I stop that?</p>
<p>One more observation - when I click on the default &quot;Hello world&quot; post that WordPress creates by default, it takes me to the correct URL.  Only the admin panel seems to not work correctly?</p>

mnj
<p>The solution was to move the contents of <code>/opts/bitnami/wordpress</code> to <code>/opts/bitnami/wordpress/wordpress</code> and to remove entirely the <code>nginx.ingress.kubernetes.io/rewrite-target</code> annotation from the ingress.</p>
