Make WordPress Core

Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#26625 closed defect (bug) (duplicate)

Issue with non standard port in redirect_canonical()

Reported by: thg2k's profile thg2k Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: Canonical Keywords:
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 "" and you access your site using an alias like "". The redirect keeps the alias host (not sure why?) BUT discards the port, so for example if the alias host is instead "" you get redirected to "", which is inconsistent and totally wrong.

I would expect one of two behaviours:
1) You get redirected to
2) You get redirected to

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 (3)

#1 @DrewAPicture
9 years 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?

#2 @chriscct7
8 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

No reporter feedback in 2 years. Closing as invalid.

#3 @johnbillion
8 years ago

  • Resolution changed from invalid to duplicate

Duplicate of #33821.

Note: See TracTickets for help on using tickets.