fixing a problem(pagination) when wordpress 3.0 is behind the firewall (in the proxy way).

There is a problem has bothered me a while when I tried to put my wp behind  my firewall. When I look at front-end everything is fine. It shows appropriate url base on your server’s  host name, but it acts differently in the back-end side.

When I log in to the back-end (admin), I checked my articles , media, pages and thems etc… ya it showed normal except the pagination part. The problem is the hyperlink didn’t show the exact link it should be.

For example, If wp is in http://192.168.11.2/wp/  and we are using http://domain.com/wp as proxy to transfer any requests to 192.168.11.2 then in the back-end pagination part, it should be like http://domain.com/wp/edit.php?paged=1,2,3……. , but it didn’t.

It shows http://192.168.11.2/wp/edit.php?paged=1,2,3… which it doesn’t work. So I’ve dug for quite a while, but no luck and leaded me only one choice. I have to hack the core code which I would not like to do if there are other choices.

Here is what I’ve done. find the file in wp-admin/includes/class-wp-list-table.php

then find the fucntion pagination( $which ) {

and replace

$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST']. $_SERVER['REQUEST_URI'];

to this

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'];

And that should do it..

Comments are closed.