below file public_html\vendor\magento\module-store\Model\Store.php around line 607 you can find getBaseurl() function you can find
$url = $this->getConfig($path);
after this line added
$url = $this->newurl($url,$secure);
after created new function like below
public function newurl($url, $secure) {
if (false !== strpos($url, self::BASE_URL_PLACEHOLDER)) {
$url = str_replace(self::BASE_URL_PLACEHOLDER, $this->_request->getDistroBaseUrl(), $url);
}
$new_secure = $secure === null ? $this->isCurrentlySecure() : (bool) $secure;
$path = $secure ? self::XML_PATH_SECURE_BASE_URL : self::XML_PATH_UNSECURE_BASE_URL;
$new_url = $this->getConfig($path);
$host = parse_url($url, PHP_URL_HOST);
$new_host = parse_url($new_url, PHP_URL_HOST);
$subdomain_url = 'http';
if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on") {
$subdomain_url .= "s";
}
$subdomain_url .= "://";
if(isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["REQUEST_URI"])){
$servername = $_SERVER["SERVER_NAME"];
$requesturi = $_SERVER["REQUEST_URI"];
$subdomain_url .= $servername . $servername;
$subdomain_host = parse_url($subdomain_url, PHP_URL_HOST);
$url = str_replace('://' . $host . '/', '://' . $_SERVER['HTTP_HOST'] . '/', $url);
} else{
$url = $new_url;
}
return $url;
}
now working as i expected