[wp-trac] [WordPress Trac] #33821: redirect_canonical does not consider port in $compare_original
WordPress Trac
noreply at wordpress.org
Wed Jun 18 08:58:09 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 has- | Focuses:
test-info |
-------------------------------------------------+-------------------------
Comment (by wojtekn):
> I got you now. I was looking in an entirely wrong direction. Anyway, I
think that maybe the auth_redirect for the second test could be considered
for another patch. Although, if I'm sincere, this is so irrelevant because
after all it's a "useless" upgrade.
Thanks for dedicating time to check it more.
> Finally, we must consider adding some unit-tests for this.
I've added tests for both issues (preserving the canonical URL scheme and
avoiding changes to the host when ports differ).
> Currently, canonical redirects are not respecting WP_HOME settings for
scheme. Furthermore, under certain circumstances, host is being rewritten
unnecessarily and this line is not being respected.
> Providing more context, we must dig into changeset [6097] and ticket
#4773 and why this line was introduced.
The changeset [6097] added a condition that prevents from redirecting to
canonical if request domain and canonical differ only in letter casing. It
was reported in #4773.
This condition was further improved by loosening the condition by adding
part that allows to redirect from www to non-www and vice versa. (#5089).
Looking into that ticket, it's not clear why this change was added there,
as the steps described in the ticket don't even tackle www and non-www
redirects. I tried removing this condition, and the www to non-www
redirects still work fine.
> I'm not confident if we could be provoking a regression by ignoring this
line with the new patch. This report was already fixed into the 2.3
version, but it did not provide the exact patches that could be causing
the trouble. Once we've better sorted this out and c if there could be no
collisions, we can move it forward.
What if we added a few more unit tests to confirm that behavior for those
cases doesn't change:
- Example.com → example.com (should not redirect)
- www.example.com → example.com (should redirect)
- example.com → www.example.com (should redirect)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33821#comment:45>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list