[wp-trac] [WordPress Trac] #36201: Admin Pagination URLs Use Wrong Hostname

WordPress Trac noreply at wordpress.org
Sun Jan 23 14:03:28 UTC 2022

#36201: Admin Pagination URLs Use Wrong Hostname
 Reporter:  grimmdude                            |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Administration                       |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing dev-         |     Focuses:
  feedback                                       |  administration

Comment (by timinaust):

 I found setting HTTP_HOST caused other redirect issues.  My workaround to
 this - providing you have access to the proxy...

 Set the proxy to add a header on requests being passed through with the
 request host name, then add the following at the end of wp-config.php.  It
 corrects pagination/sorting for both normal and ajax admin calls.

 Example is for apache proxy, nginx proxy should work exactly the same if
 you add the same header.

  * Filter to fix up admin URLs when running behind a reverse proxy.
  * On the proxy, add a header to requests for X_ORIGINAL_HOST.
  * On and apache proxy add the following RequestHeader line in the proxy
  *   <Location ...>
  *     ProxyPass ....
  *     ProxyPassReverse ....
  *      ....
  *     RequestHeader set X-Original-Host "expr=%{HTTP_HOST}"
  *    ....
  *   </Location>
 function proxied_url_rewrite ($url,$scheme,$orig_scheme) {
         if ($_SERVER["HTTP_X_ORIGINAL_HOST"] && ($scheme == "https" ||
 $scheme == "http") && $_SERVER['HTTP_HOST'] !=
                 $url = str_replace("://".$_SERVER['HTTP_HOST']."/",
         return $url;
 if ( is_admin() && $_SERVER["HTTP_X_IS_REVERSE_PROXY"])


 You may also need to add in wp-config.php if you are proxying from https
 -> http
 $_SERVER['HTTPS'] = 'on';

Ticket URL: <https://core.trac.wordpress.org/ticket/36201#comment:40>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list