WordPress.org

Make WordPress Core

Ticket #27954: 27954.diff

File 27954.diff, 1.4 KB (added by thomaswm, 4 years ago)

Redirect frontend to HTTPS if FORCE_SSL constant is set to true

  • wp-includes/canonical.php

     
    387387                $redirect['port'] = $user_home['port'];
    388388        else
    389389                unset($redirect['port']);
     390       
     391        // Redirect to HTTPS if the FORCE_SSL constant is set to true
     392        if ( defined( 'FORCE_SSL' ) && FORCE_SSL )
     393                $redirect['scheme'] = 'https';
    390394
    391395        // trailing /index.php
    392396        $redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']);
     
    445449                ( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) )
    446450                $redirect['host'] = $original['host'];
    447451
    448         $compare_original = array( $original['host'], $original['path'] );
     452        $compare_original = array( $original['scheme'], $original['host'], $original['path'] );
    449453
    450454        if ( !empty( $original['port'] ) )
    451455                $compare_original[] = $original['port'];
     
    453457        if ( !empty( $original['query'] ) )
    454458                $compare_original[] = $original['query'];
    455459
    456         $compare_redirect = array( $redirect['host'], $redirect['path'] );
     460        $compare_redirect = array( $redirect['scheme'], $redirect['host'], $redirect['path'] );
    457461
    458462        if ( !empty( $redirect['port'] ) )
    459463                $compare_redirect[] = $redirect['port'];