[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
Thu Jan 21 21:49:32 UTC 2016


#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
-------------------------------+------------------------------
Changes (by johnbillion):

 * keywords:   => reporter-feedback


Old description:

> I was having an issue with the  wp_admin_canonical_url() function in wp-
> admin/includes/misc.php and I have a suggested fix
>
> I am running word press behind a reverse nginx proxy on a different box
> so my main site is at http://www.rammount.com and the blog is at
> http://www.rammount.com/blog
>
> The blog url is set in the WordPress configuration. But when you log into
> the admin section the wp_admin_canonical_url() function does not pick up
> the configured url instead it constructs the url without the /blog. This
> of course breaks links in the admin section, constantly redirecting
> things to http://www.rammount.com without the /blog
>
> by changing the following line:
> $current_url  = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] .
> $_SERVER['REQUEST_URI'] );
>
> to:
> $current_url  =
> set_url_scheme(home_url(add_query_arg(array(),$wp->request)) .
> $_SERVER['REQUEST_URI']);
>
> the problem is solved. the proper url is created and as such the links in
> the admin section that use the canonical url link function correctly.
>
> Hoping to have this change evaluated for inclusion, so that I don't have
> to remake this edit every time one of my designers updates the WordPress
> installation?

New description:

 I was having an issue with the  wp_admin_canonical_url() function in wp-
 admin/includes/misc.php and I have a suggested fix

 I am running word press behind a reverse nginx proxy on a different box so
 my main site is at http://www.rammount.com and the blog is at
 http://www.rammount.com/blog

 The blog url is set in the WordPress configuration. But when you log into
 the admin section the wp_admin_canonical_url() function does not pick up
 the configured url instead it constructs the url without the /blog. This
 of course breaks links in the admin section, constantly redirecting things
 to http://www.rammount.com without the /blog

 by changing the following line:
 `$current_url  = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] .
 $_SERVER['REQUEST_URI'] );`

 to:
 `$current_url  =
 set_url_scheme(home_url(add_query_arg(array(),$wp->request)) .
 $_SERVER['REQUEST_URI']);`

 the problem is solved. the proper url is created and as such the links in
 the admin section that use the canonical url link function correctly.

 Hoping to have this change evaluated for inclusion, so that I don't have
 to remake this edit every time one of my designers updates the WordPress
 installation?

--

Comment:

 Thanks for the ticket @ilude.

 This sounds like it might be a problem with your reverse proxy
 configuration whereby the full URL path is not being passed through from
 Nginx.

 Can you let us know what the value of `$_SERVER['REQUEST_URI']` is when
 accessing your blog's admin area? If it's empty, or doesn't contain the
 `/blog` prefix, then this is an issue with the your reverse proxy
 implementation (possibly a missing `fastcgi_param` setting).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35561#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list