Skip to content

Commit 96e424e

Browse files
build canonical abs URL from admin URL
1 parent c5308d4 commit 96e424e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/wp-admin/includes/misc.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,11 @@ function wp_admin_canonical_url() {
14061406
}
14071407

14081408
// Ensure we're using an absolute URL.
1409-
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1409+
// Build the canonical URL using the configured admin URL to avoid issues
1410+
// with reverse proxies that expose a different host via HTTP_HOST.
1411+
$path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
1412+
$query = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY );
1413+
$current_url = admin_url( ltrim( $path, '/' ) . ( $query ? '?' . $query : '' ) );
14101414
$filtered_url = remove_query_arg( $removable_query_args, $current_url );
14111415

14121416
/**

0 commit comments

Comments
 (0)