Opened 3 months ago
Issue with non standard port in redirect_canonical()
|Reported by:||thg2k||Owned by:|
I just loaded in my local environment a production wordpress installation (files and db) and saw a weird redirection happening when I tried to load it.
The issue has to do with option home_url and redirect_canonical(), in particular i tracked down the following offending lines:
// Ignore differences in host capitalization, as this can lead to infinite redirects // Only redirect no-www <=> yes-www if ( strtolower($original['host']) == strtolower($redirect['host']) || ( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) ) $redirect['host'] = $original['host'];
The problem seems to happen if home_url is set to for example "http://hello.com" and you access your site using an alias like "http://blablabla.com". The redirect keeps the alias host (not sure why?) BUT discards the port, so for example if the alias host is instead "http://blablabla.com:81" you get redirected to "http://blablabla.com", which is inconsistent and totally wrong.
Either way would be fine to me, because it would be consistent. If someone would be so kind to explain me also why you don't want to redirect based on host capitalization I would really appreciate and maybe I can formulate a good patch for this issue.