diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php
index a02ab793cee3..68a33255b821 100644
a
|
b
|
function redirect_canonical( $requested_url = null, $do_redirect = true ) { |
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | | if ( ! $requested_url && isset( $_SERVER['HTTP_HOST'] ) ) { |
| 66 | // www.example.com vs. example.com |
| 67 | $user_home = parse_url( home_url('/') ); |
| 68 | |
| 69 | if ( ! $requested_url ) { |
67 | 70 | // Build the URL in the address bar. |
68 | | $requested_url = is_ssl() ? 'https://' : 'http://'; |
69 | | $requested_url .= $_SERVER['HTTP_HOST']; |
| 71 | $requested_url = is_ssl() ? 'https://' : 'http://'; |
| 72 | if ( isset( $_SERVER['HTTP_HOST'] ) ) { |
| 73 | $requested_url .= $_SERVER['HTTP_HOST']; |
| 74 | } else { |
| 75 | // Fallback for http1.0 where requested host and port are unknown |
| 76 | // In this case correct redirect no-www <=> yes-www is not possible |
| 77 | $requested_url .= $user_home['host']; |
| 78 | if ( ! empty( $user_home['port'] ) ) { |
| 79 | $requested_url .= ':' . $user_home['port']; |
| 80 | } |
| 81 | } |
70 | 82 | $requested_url .= $_SERVER['REQUEST_URI']; |
71 | 83 | } |
72 | 84 | |
… |
… |
function redirect_canonical( $requested_url = null, $do_redirect = true ) { |
570 | 582 | $redirect = parse_url( $redirect_url ); |
571 | 583 | } |
572 | 584 | |
573 | | // www.example.com vs. example.com |
574 | | $user_home = parse_url( home_url() ); |
575 | | |
576 | 585 | if ( ! empty( $user_home['host'] ) ) { |
577 | 586 | $redirect['host'] = $user_home['host']; |
578 | 587 | } |