Wrong url in sortable column headers & pagination in the admin, when behind a proxy

Ok so apparently this site is behind a firewall or proxy.

On lines 491 and 658 in wp-admin/includes/class-wp-list-table.php, replace this line $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

with

if(!empty($_SERVER['HTTP_X_FORWARDED_HOST'])){
$hostname = $_SERVER['HTTP_X_FORWARDED_HOST'];
} else {
$hostname = $_SERVER['HTTP_HOST'];
}
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $hostname . $_SERVER['REQUEST_URI'];

Thanks goes to http://www.stat.sinica.edu.tw/alvin/blog/archives/1129/ for posting this fix.

Now the question is there any way to do this without editing core files? If anyone can post that I’ll mark that as the accepted answer, I haven’t had to modify my core yet, and I’d prefer to keep it that way.

Leave a Comment