Toggle Nav
My Cart 0

Magento 2 get base URL in phtml file | Get Base Secure URL

Magento 2 get base URL in phtml file | Get Base Secure URL

You can get base URL of front-end using Object Manager. Try below code.

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance(); 

$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
$store = $storeManager->getStore();
echo $baseUrl = $store->getBaseUrl();
echo $baseSecureUrl = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true);

July 9, 2018
Did you like this post?
0
0