[wp-trac] [WordPress Trac] #33821: redirect_canonical does not consider port in $compare_original

WordPress Trac noreply at wordpress.org
Fri Jun 13 15:37:28 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 changes-  |     Focuses:
  requested                                      |
-------------------------------------------------+-------------------------

Comment (by SirLouen):

 Replying to [comment:29 wojtekn]:
 > @SirLouen I opened a PR with a patch that fixes the issue from my
 testing steps.

 I've been playing around. This brought me some memory of some tests I did
 some months ago with ngrok and `wordpress-develop`. I was trying to set up
 a remote test site and I had to install a plugin that managed some
 canonical redirects I can't remember now which and why.

 The thing here is that if I set up my HTTPS environment in port 8890
 https://github.com/WordPress/wordpress-develop/pull/8787

 And then I run ngrok with something like `ngrok http
 https://localhost:8890`
 Everything works well within WP (without patch and without any other mods,
 straight out of the box).

 Now I'm testing this, with regular http connection and with https

 === Without the patch:

 {{{
 > curl -I http://localhost:8889
 HTTP/1.1 301 Moved Permanently
 Server: nginx/1.27.5
 Date: Fri, 13 Jun 2025 15:09:21 GMT
 Content-Type: text/html; charset=UTF-8
 Connection: keep-alive
 X-Powered-By: PHP/8.2.28
 X-Redirect-By: WordPress
 Location: http://localhost/
 }}}

 ===  With the patch:
 {{{
 > curl -I http://localhost:8889
 HTTP/1.1 301 Moved Permanently
 Server: nginx/1.27.5
 Date: Fri, 13 Jun 2025 15:09:46 GMT
 Content-Type: text/html; charset=UTF-8
 Connection: keep-alive
 X-Powered-By: PHP/8.2.28
 X-Redirect-By: WordPress
 Location: http://2854-80-102-99-22.ngrok-free.app/
 }}}

 === With my patch and without your patch:
 {{{
 > curl -k -I https://localhost:8890
 HTTP/1.1 301 Moved Permanently
 Server: nginx/1.27.5
 Date: Fri, 13 Jun 2025 15:29:08 GMT
 Content-Type: text/html; charset=UTF-8
 Connection: keep-alive
 X-Powered-By: PHP/8.2.28
 X-Redirect-By: WordPress
 Location: https://localhost/
 }}}

 === With my patch and your patch:
 {{{
 > curl -k -I https://localhost:8890
 HTTP/1.1 301 Moved Permanently
 Server: nginx/1.27.5
 Date: Fri, 13 Jun 2025 15:28:17 GMT
 Content-Type: text/html; charset=UTF-8
 Connection: keep-alive
 X-Powered-By: PHP/8.2.28
 X-Redirect-By: WordPress
 Location: https://ba15-80-102-99-22.ngrok-free.app/
 }}}

 True that the location is wrong without patch. And note that theoretically
 the canonical redirection should be pointing to https regardless of
 curling the http or https version of localhost, as we set this in the
 defines right?

 The thing is that If I go into https://ba15-80-102-99-22.ngrok-free.app I
 can't see any problems
 Even the `rel=canonical` are pointing to the right place

 The problem is that I don't know exactly what problems I should be
 experiencing.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/33821#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list