This looks like wp-admin remove the subfolder URL but it’s not the same problem, because the subfolder part is not a subfolder.
I’m working on a clean VM as a host for Docker containers. I have a dockerized WordPress listening on 8080 on the VM.
I can hit WordPress at http://<vm_ip>:8080
and install just fine. It takes me to the backend at http://<vm_ip>:8080/wp-admin/
and everything works as expected.
Now I’d like to access my blog at http://<vm_ip>/blog/
so I set up nginx on the VM to proxy requests per location :
upstream blog {
server localhost:8080;
}
server {
listen 80;
server_name <vm_ip> localhost;
location /blog/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Nginx-Proxy true;
proxy_pass http://blog/;
}
}
This is temporary as nginx will probably end up dockerized, but that requires custom images ; one thing at a time…
Also with an actual domain name, I would use subdomains so that would take care of my problem
I hit http://<vm_ip>/blog/
and I get to the install, but the static files’ url are not correct : http://blog/wp-includes/css/...
so the UI is a bit raw.
I move on with the install. It works and takes me to http://<vm_ip>/blog/wp-admin/install.php?step=2
but the Connect button points to http://blog/wp-login.php
so I get a 404.
I need to make a change directly in the db : site_url and home (in wp_options
) are set to http://blog
so I update them both to http://<vm_ip>/blog
.
Now the frontend works just fine, but the backend has problems. While most links are OK, some buttons’ href miss the blog part : http://<vm_ip>/wp-admin
so it takes me nowhere.
Those buttons usually have some kind of submit role :
- the close button (top left) in Appearance > Customize (points to
http://wp-admin/
) - the Save button in Settings > General (submit for
<form action="options.php">
)
What’s funny is it’s not consistent : the Save button on Page > Add works just fine (though it throws a DOMException : Failed to execute 'replaceState' on 'History': A history state object with URL 'http://blog/wp-admin/post.php?post=15&action=edit' cannot be created in a document with origin 'http://<vm_ip>' and URL 'http://<vm_ip>/blog/wp-admin/post.php?post=15&action=edit&message=1'
)
Is it something with the site_url
and home
options ?
Should I search the admin templates for the incomplete urls placeholders ?
Is there some hook or filter to force the right url ?