[wp-trac] [WordPress Trac] #51700: Infinite redirect loop error when blog site is rewritten and real domain on another server

WordPress Trac noreply at wordpress.org
Tue Nov 3 15:17:59 UTC 2020


#51700: Infinite redirect loop error when blog site is rewritten and real domain on
another server
--------------------------+------------------------------
 Reporter:  vladop        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Canonical     |     Version:  5.5.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by apedog):

 You shouldn't have to modify WordPress core.
 There's a filter hook on line 753:

 {{{#!php
 $redirect_url = apply_filters( 'redirect_canonical', $redirect_url,
 $requested_url );
 }}}

 You can add your modified version of core's {{{redirect_canonical()}}} (or
 a function with your own logic) to that hook and save it in a plugin. Like
 so:
 {{{#!php
 function my_custom_redirect_canonical( $redirect_url, $requested_url ){
     // your custom logic here
     return $redirect_url;
 }
 add_filter( 'redirect_canonical', 'my_custom_redirect_canonical', 10, 2 );
 }}}

 It should keep working whenever you upgrade WordPress core.

 This is not to say that your report is, or isn't, a bug.
 The strong coupling to {{{$_SERVER}}} superglobal is regrettable.

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


More information about the wp-trac mailing list