Magento 2 – How to Get Admin Base URL

adminhtmlbackendbase-urlmagento2

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

$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');

echo $storeManager->getStore()->getBaseUrl();exit;

This only gives the frontend base URL. How to get admin side URL?

Best Answer

You can use following code directly in your phtml file to get admin URL.

echo $this->helper('Magento\Backend\Helper\Data')->getHomePageUrl();