$juri = JUri::getInstance(); $rootUrl = $juri->root(); echo $rootUrl;
define('_JEXEC', 1); // Import Joomla Platform library define('JPATH_BASE', '/path/to/joomla/installation'); require_once JPATH_BASE . '/includes/defines.php'; require_once JPATH_BASE . '/includes/framework.php'; // Get root URL of Joomla installation $juri = JUri::getInstance(); $rootUrl = $juri->root(); echo $rootUrl;In this example, we first define the _JEXEC constant, which tells the Joomla Platform library to initialize itself. We then import the Joomla framework files and set the JPATH_BASE constant to the path of our Joomla installation. Finally, we retrieve the JUri instance and use the root() method to get the root URL of the Joomla installation. The URL is then displayed on the screen. Package Library: Joomla Platform Library.