[wp-trac] [WordPress Trac] #35561: function wp_admin_canonical_url() not using configured site url when constructing canonical url link tag
WordPress Trac
noreply at wordpress.org
Fri Feb 3 16:22:52 UTC 2017
#35561: function wp_admin_canonical_url() not using configured site url when
constructing canonical url link tag
-------------------------------+------------------------------
Reporter: ilude | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 4.4.1
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses: administration
-------------------------------+------------------------------
Comment (by higuita):
I also had this problem and IMHO, wp-admin-canonical is broken as it
assumes only one way of working.
In my setup, i have a main site and want to add a subdirectory blog to the
site:
main site: www.example.com
blog: www.example.com/blog
we are using wpengine as a blog backend, so i configured the site url and
wordpress url to https://www.example.com/blog and setup the main site to
do a reverse proxy to the blog:
{{{
location ^~ /blog {
proxy_set_header HOST $host;
proxy_set_header Proxy "";
proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# notice the ending /, so the /blog is converted to / in the backend
proxy_pass https://wpengine/ ;
}
}}}
I can not change the wpengine config so that is accepts /blog/ requests
directly, i have to
convert then to / for it to work.
With this the public wordpress works fine, but the wp-admin tried to
access https://www.example.com/wp-admin instead of
https://www.example.com/blog/wp-admin. This is only because of wp-admin-
canonical, removing that, all works fine.
{{{
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] .
$_SERVER['REQUEST_URI'] );
}}}
Here we we can see that wordpress is assuming that what it gets is the
final URL, that might not be the true. Not all people can control the
wordpress install and may prefer to manage this in the reverse proxy.
Think in wordpress hosting, or docker images that work both in / and
/folder setups, without any special change other than the site and home
url.
wp-admin-canonical must not assume how the site works, it should trust the
site or wordpress url and let the reverse proxy take care of the rest.
The simple fact that this [https://wordpress.org/plugins/remove-wp-
canonical-url-admin-hack/ plugin] exists proves that wordpress is wrongly
assuming how everything should work. There are many setups out there, not
all work the same.
Pleas change this or give a simple way to disable it. The plugin is a
workaround, but only after people got this error and lost several hours
trying to figure why this is not working
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35561#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list