0

I recently handed off a WordPress site I developed to an IT team that is in charge of my client's web environment. They aren't WordPress people and I don't have any access to the environment. There are currently issues as a result of the environment they are using, which I'll explain:

  • Server A (Web server)
    • Domain name (http://example.com) points here, rewrites are made, and traffic is routed to either Server B or C.
  • Server B (App server)
  • Server C (WordPress server)

Next, some important notes:

  • The WordPress Address and Site Address in WP are set to http://example.com/blog.
  • The WordPress database has been searched and replaced so all URLs are http://example.com/blog
  • Pages and assets in the frontend are being served correctly

Despite these facts, there are links in the backend of WordPress that are still using the server's IP address URL. For example, all of the pagination controls in post/page lists.

Also, any kind of form in the backend is broken. For example, if I try to delete a plugin, the form which handles the delete button have the POST action mapped to /wp-admin/plugins.php?action=delete-selected... This of course means it's ignoring the /blog/ subdirectory in the Site Address, which then 404s. I think this particular issue is a result of Server A trying to rewrite that request.

There are other problems, but they all boil down to WordPress seemingly not knowing exactly what its URL is. My opinion is that because of Server C's setup, it is causing the wrong URL to be used in places where the PHP is doing things like this:

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

HTTP_HOST uses the Host header, if one is present, otherwise it must grab the value from the server, which is currently the IP address.

My question is... how do we tweak this setup and fix these URL issues in WordPress?

1
  • Of note, you can't just do a text search replace on a database or export to change a WordPress sites URL, as it's stored in PHP serialised structures in some options, and these structures are corrupted if the new URL has a different length
    – Tom J Nowell
    Commented Mar 13, 2015 at 16:15

1 Answer 1

0

here is the solution!

http://www.iconwebsolutions.info/wordpress-admin-prevnext-page-links-still-pointing-to-the-old-site/

Open the file wp-admin/includes/class-wp-list-table.php

Search for ‘function pagination’ You will find below line of code to set the current url $current_url = set_url_scheme( ‘http://’ . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’] );

$current_url is built using $_SERVER[‘HTTP_HOST’] which will not work for the servers running under proxies so change this URL or basically hardcode it with your server URL as below:

$current_url = set_url_scheme( ‘http://serverurl.com’ . $_SERVER[‘REQUEST_URI’] );

1
  • 1
    Welcome. Please format your code.
    – tfrommen
    Commented Sep 16, 2015 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.