Administration: Use admin_url() for canonical URL#1504
Administration: Use admin_url() for canonical URL#1504jefferyto wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
Please merge this code, the problem is critical for running wordpress under a prefix / context. |
Currently, wp_admin_canonical_url() uses $_SERVER['HTTP_HOST'] to build an admin page's canonical URL. This URL will point to an incorrect host if $_SERVER['HTTP_HOST'] does not match the site URL host, e.g. when Wordpress is used behind a reverse proxy. This uses admin_url() so that the canonical URL will take the configured site URL into account. Trac ticket: https://core.trac.wordpress.org/ticket/35561
ffd8059 to
340b484
Compare
|
The patch that was eventually merged doesn't solve this problem, it's currently near-impossible to host Wordpress behind a reverse proxy that removes the subpath from the request before forwarding it to the container. This fix is basically required for a k8s+wordpress setup. Some people do a filesystem symlink and don't take away the subpath at the ingress, but that hack has various real world problems once you start getting involved with it, and it's a hack anyway. Code-wide I think it would be better to replicate the behavior of the main site and use siteurl, although I understand that the admin page has to have some kind of fallback functionality when siteurl is wrong. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @hanspoo, @p4block. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Currently,
wp_admin_canonical_url()uses$_SERVER['HTTP_HOST']to build an admin page's canonical URL. This URL will point to an incorrect host if$_SERVER['HTTP_HOST']does not match the site URL host, e.g. when Wordpress is used behind a reverse proxy.This uses
admin_url()so that the canonical URL will take the configured site URL into account.Trac ticket: https://core.trac.wordpress.org/ticket/35561
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.