Retrieving all URL paths in Magento

August 5, 2010 | In: Magento

Magento comes with built in function for retrieving URL paths. Function is called getBaseUrl() and its located under Mage class. However, function is not documented as it should be. Documentation only states that function retrieves $type parametar which is by default equal to “base”.

Here is the list of all the available parameters I found. As you can see, they all come from Mage_Core_Model_Store.


Where  is the url of your site. If you don’t provide any parameters to getBaseUrl() function you would retrieve the same path as with URL_TYPE_LINK parametar.

Remember, you need to echo out these statements to the browser, because they each return a string, so you need to output that string like

    echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);