Make WordPress Core

Opened 2 years ago

Last modified 19 months ago

#26625 new defect (bug)

Issue with non standard port in redirect_canonical()

Reported by: thg2k Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.7
Component: Canonical Keywords: reporter-feedback
Focuses: Cc:


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.

I would expect one of two behaviours:
1) You get redirected to http://hello.com/
2) You get redirected to http://blablabla.com:81/

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.

Change History (1)

#1 @DrewAPicture
19 months ago

  • Keywords reporter-feedback added
  • Version changed from 3.7.1 to 2.7

Hi thg2k, thanks for the report, sorry it took so for a reply.

If you're still seeing this issue, would you mind explaining more precisely how you're configuring your alias hosts and provide steps to reproduce?

Note: See TracTickets for help on using tickets.