[wp-trac] [WordPress Trac] #33821: redirect_canonical does not consider port in $compare_original
WordPress Trac
noreply at wordpress.org
Thu Jun 12 11:51:41 UTC 2025
#33821: redirect_canonical does not consider port in $compare_original
-------------------------------------------------+-------------------------
Reporter: willshouse | Owner: (none)
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Future
| Release
Component: Canonical | Version: 2.3
Severity: normal | Resolution:
Keywords: has-patch needs-unit-tests needs- | Focuses:
test-info close |
-------------------------------------------------+-------------------------
Comment (by wojtekn):
> That's the part that doesn't really make sense here - the port should
always be in HTTP_HOST when it's a non-standard port: it's required by the
HTTP specification. So I don't see how it's possible to actually reproduce
this (unless perhaps you use a buggy/malfunctioning HTTP client?)
@siliconforks in the comment above
(https://core.trac.wordpress.org/ticket/33821#comment:10), I showed how
those end up being compared without port, and how the redirect host is
replaced with the original host.
To share more context, I initially reproduced it in WordPress Studio, and
we "solved" it by installing custom mu-plugin to handle this specific
redirect (see
https://github.com/Automattic/studio/pull/936/commits/f9c393052282fd86dd176bedf91f0049d328c6a5)
The issue was happening when the site was accessed via a non-SSL URL with
port (e.g. http://localhost:8888), but the canonical URL was set to a
custom domain without a port (http://some.custom.domain.dev).
I would expect that the users will be redirected from
http://localhost:8888 to http://some.custom.domain.dev, but in reality
they were redirected to http://localhost.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33821#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list