Static home page redirect error using post name premalinks behind reverse proxy
-
In a WP site behind a reverse proxy all was working ok.
I then set a static home page and all was still working.
After I set post name permalinks, all pages kept working except home page, which had redirect errors.
After some time spent researching the problem, I found that the problem was on line 69 ofwp-includes/canonical.php
:$requested_url .= $_SERVER['HTTP_HOST'];
.
Instead of the value in$_SERVER['HTTP_HOST']
, the value in$_SERVER['HTTP_X_FORWARDED_HOST']
should be used.
So to fix the problem I added the following line in mywp-config.php
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
I wonder if that could be definitively fixed changing line 69 ofwp-includes/canonical.php
with$requested_url .= isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST'];
.
- The topic ‘Static home page redirect error using post name premalinks behind reverse proxy’ is closed to new replies.