diff --git a/src/URLFixer.php b/src/URLFixer.php index cd74c73..85a0b48 100644 --- a/src/URLFixer.php +++ b/src/URLFixer.php @@ -50,12 +50,15 @@ public function fixSiteURL(string $url): string } /** - * Ensure that the network site URL contains the /wp subdirectory. + * Ensure that the network site URL contains the /wp subdirectory and uses the current request host. */ public function fixNetworkSiteURL(string $url, string $path): string { $path = ltrim($path, '/'); - $url = substr($url, 0, strlen($url) - strlen($path)); + + $scheme = is_ssl() ? 'https' : 'http'; + $host = $_SERVER['HTTP_HOST'] ?? parse_url($url, PHP_URL_HOST); + $url = $scheme . '://' . $host . '/'; if (substr($url, -3) !== 'wp/') { $url .= 'wp/';