Hi I am trying to implement add extra key to base url example my base url:: abcd.com if user click on any key with base_url like below user entered url :: pawan.abcd.com site need set new theme if pawan key found my custom table. If not fount i need to redirect to home page or base url means site will work regular format if key found only new theme will assign can you please tell how can achieve this.

Present my site abcd.com if i click pawan.abcd.com it redirecting to abcd.com i am not redirecting but it redirecting automatically i have installed wild card ssl like *.abcd.com

can any one tell how to stop that automatic redirection

  • 1
    i think you are talking about multi-site which is covered here devdocs.magento.com/guides/v2.0/config-guide/multi-site/…
    – Anthony
    May 30, 2019 at 0:34
  • @Anthony i dont want multi site i know that concept.for every master customer they able to give their name to in-front of base url.example i am master customer i cam give some name like pawan based that name master custoemr can access site pawan.abcd.com if customer open i can assign new theme
    – Pawankumar
    May 30, 2019 at 11:50

1 Answer 1


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.