Magento2 – Get Store URL Without Store Code [SOLVED]

base-urlmagento2phtml

How to get Configuration->Web->Base URLs -> Base URL in multi store magento 2. I have enabled Add Store Code to Urls

I have use on phtml page but it return me url with store code and I need only base url without store code:

<?php echo $block->getBaseUrl();?>

Output of above code is www.example.com/de and my requirement is www.example.com

This is magento1 code.

Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_UNSECURE_URL);

I need it in magento 2.

Best Answer

I have found solution. Bellow is my code.

<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$conf = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue("web/unsecure/base_url");?>

Thanks.

Related Topic