Make WordPress Core

Ticket #34800: canonical.php.2.diff

File canonical.php.2.diff, 1.4 KB (added by sevcsik, 9 years ago)

canonical.php to use site_url host instead of original host (git diff version)

  • wordpress/wp-includes/canonical.php

    diff --git a/wordpress/wp-includes/canonical.php b/wordpress/wp-includes/canonical.php
    index f75a72e..3a8b174 100644
    a b function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    7070        if ( false === $original )
    7171                return;
    7272
     73        $site = @parse_url(get_site_url());
     74
    7375        // Some PHP setups turn requests for / into /index.php in REQUEST_URI
    7476        // See: https://core.trac.wordpress.org/ticket/5017
    7577        // See: https://core.trac.wordpress.org/ticket/7173
    function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    7779        // $original['path'] = preg_replace('|/index\.php$|', '/', $original['path']);
    7880
    7981        $redirect = $original;
     82        // enforce the same host as site_url to not break CDN setups
     83        $redirect['host'] = $site['host'];
     84
    8085        $redirect_url = false;
    8186
    8287        // Notice fixing
    function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    422427        // Only redirect no-www <=> yes-www
    423428        if ( strtolower($original['host']) == strtolower($redirect['host']) ||
    424429                ( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) )
    425                 $redirect['host'] = $original['host'];
     430                $redirect['host'] = $site['host'];
    426431
    427432        $compare_original = array( $original['host'], $original['path'] );
    428433