Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#6890 closed defect (bug) (fixed)

Canonical redirection broken for empty host in 'home' option

Reported by: thenlich Owned by: markjaquith
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.5.1
Component: General Keywords: has-patch
Focuses: Cc:


The canonical redirection of the host part (e.g. www.example.com vs example.com) is broken if get_option('home') returns an empty host part. It returns an invalid redirect in this case.

Setting the 'home' option to an empty host name (e. g. '/') is necessary if the blog needs to be reachable from different domains or protocols (HTTP/HTTPS) without redirecting to a particular one, or when the resulting HTML output should be relocatable (not contain protocol nor hostname).

Attachments (1)

patch-canonical-nohost.patch (407 bytes) - added by thenlich 8 years ago.

Download all attachments as: .zip

Change History (8)

#1 @ryan
8 years ago

  • Owner changed from anonymous to markjaquith

#2 @Otto42
8 years ago

This seems to me to be very much an edge case that would be better handled by simply disabling canonical redirection entirely, via a plugin or something.

#3 @thenlich
8 years ago

Such an option would be useful. It would be even better to (optionally) disable redirection not entirely, but selectively (for scheme:/host/path).

But that is independent from this bug: if siteurl does not contain a hostname, we cannot rewrite to it. But since a redirect needs an absolute URL, we must use the original from the request in this case.

#4 @thenlich
8 years ago

  • Keywords has-patch added

#5 @jergendutch
8 years ago

  • Cc jergendutch@… added

This feature is sorely needed by people using wordpress in a development/staging versus live environment where the same config must be used in both places, and so live should not get a development hostname by accident.

#6 @markjaquith
8 years ago

  • Milestone set to 2.6

if siteurl does not contain a hostname, we cannot rewrite to it

True. So it's a good patch from a CYA perspective, even if your intended use is unorthodox.

#7 @markjaquith
8 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [7916]) Do not use the "home"-supplied host for canonical redirects if no host is there specified. props thenlich. fixes #6890

Note: See TracTickets for help on using tickets.